From 7383ea6a35a249a87780b66aba856be6c5c40963 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 17 Dec 2015 23:47:50 +0100 Subject: [PATCH] properly copy plugin state when duplicating routes. #6709 This is not a really elegant solution. Something had to come up and ruin the neatness of the thread-private regenerate_xml_or_string_ids :) --- libs/ardour/plugin_insert.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 551602324a..b56419096e 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -1113,6 +1113,18 @@ PluginInsert::set_state(const XMLNode& node, int version) } } + PBD::ID this_id = this->id(); + + 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 ()); + } + } + Processor::set_state (node, version); for (niter = nlist.begin(); niter != nlist.end(); ++niter) { @@ -1124,14 +1136,23 @@ 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) { - (*i)->set_insert_id (this->id()); + if (!regenerate_xml_or_string_ids ()) { + (*i)->set_insert_id (this->id()); + } (*i)->set_state (**niter, version); + if (regenerate_xml_or_string_ids ()) { + (*i)->set_insert_id (this_id); + } } break; } } + 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