summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-12-18 14:55:33 +0100
committerRobin Gareus <robin@gareus.org>2015-12-18 14:55:33 +0100
commit6e7ce525f71077bd6167abec41a611db675c4026 (patch)
treeea7fffe7ab17ab8b5e22e459043064f7ad78a2c8 /libs/ardour
parent3eb04c3c2320ba60185e6efde170b562c3518e50 (diff)
cleaner version of 7383ea6a (duplicate plugin state)
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/plugin_insert.cc39
1 files changed, 22 insertions, 17 deletions
diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc
index 1c9c573e42..827e6d19f4 100644
--- a/libs/ardour/plugin_insert.cc
+++ b/libs/ardour/plugin_insert.cc
@@ -1113,19 +1113,14 @@ PluginInsert::set_state(const XMLNode& node, int version)
}
}
- PBD::ID this_id = this->id();
+ Processor::set_state (node, version);
- if (regenerate_xml_or_string_ids ()) {
- /* when duplicating a track, we need to use the
- * original ID for loading plugin state (from file)
- */
- const XMLProperty* prop;
- if ((prop = node.property ("id")) != 0) {
- plugin->set_insert_id (prop->value ());
- }
- }
+ PBD::ID new_id = this->id();
+ PBD::ID old_id = this->id();
- Processor::set_state (node, version);
+ if ((prop = node.property ("id")) != 0) {
+ old_id = prop->value ();
+ }
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
@@ -1136,12 +1131,26 @@ PluginInsert::set_state(const XMLNode& node, int version)
if ((*niter)->name() == plugin->state_node_name()) {
for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
+ /* Plugin state can include external files which are named after the ID.
+ *
+ * If regenerate_xml_or_string_ids() is set, the ID will already have
+ * been changed, so we need to use the old ID from the XML to load the
+ * state and then update the ID.
+ *
+ * When copying a plugin-state, route_ui takes care of of updating the ID,
+ * but we need to call set_insert_id() to clear the cached plugin-state
+ * and force a change.
+ */
if (!regenerate_xml_or_string_ids ()) {
- (*i)->set_insert_id (this->id());
+ (*i)->set_insert_id (new_id);
+ } else {
+ (*i)->set_insert_id (old_id);
}
+
(*i)->set_state (**niter, version);
+
if (regenerate_xml_or_string_ids ()) {
- (*i)->set_insert_id (this_id);
+ (*i)->set_insert_id (new_id);
}
}
@@ -1149,10 +1158,6 @@ PluginInsert::set_state(const XMLNode& node, int version)
}
}
- if (regenerate_xml_or_string_ids ()) {
- plugin->set_insert_id (this_id);
- }
-
if (version < 3000) {
/* Only 2.X sessions need a call to set_parameter_state() - in 3.X and above