summaryrefslogtreecommitdiff
path: root/libs/ardour/io.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-03-16 22:36:06 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-03-16 22:36:06 +0000
commit1b830d59428f51179094f917a09b0acc16f31c8e (patch)
treeb5d6c6b64fee0bbc4dfe9485d886cfa99f8e1888 /libs/ardour/io.cc
parentf1638d365e2f59d09c810e362b6245fe949b7936 (diff)
continue the saga of Rewrite The XML Node So That It Can Be Used To Set Another Object's State by descending into an IO node to fix the names of its ports as used in connection info. allows copies of sends etc. to retain the same connections as the original (with new names, obviously)
git-svn-id: svn://localhost/ardour2/branches/3.0@11717 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/io.cc')
-rw-r--r--libs/ardour/io.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index 3805d7ac83..93ab043308 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -614,6 +614,8 @@ IO::set_state (const XMLNode& node, int version)
return -1;
}
+ cerr << "IO::set state, connecting legal ? " << connecting_legal << endl;
+
if (connecting_legal) {
if (make_connections (node, version, false)) {
@@ -956,6 +958,44 @@ IO::make_connections (const XMLNode& node, int version, bool in)
return 0;
}
+void
+IO::prepare_for_reset (XMLNode& node, const std::string& name)
+{
+ /* reset name */
+ node.add_property ("name", name);
+
+ /* now find connections and reset the name of the port
+ in one so that when we re-use it it will match
+ the name of the thing we're applying it to.
+ */
+
+ XMLProperty* prop;
+ XMLNodeList children = node.children();
+
+ for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
+
+ if ((*i)->name() == "Port") {
+
+ prop = (*i)->property (X_("name"));
+
+ if (prop) {
+ string new_name;
+ string old = prop->value();
+ string::size_type slash = old.find ('/');
+
+ if (slash != string::npos) {
+ /* port name is of form: <IO-name>/<port-name> */
+
+ new_name = name;
+ new_name += old.substr (old.find ('/'));
+
+ prop->set_value (new_name);
+ }
+ }
+ }
+ }
+}
+
int
IO::make_connections_2X (const XMLNode& node, int /*version*/, bool in)