Update cAutomationControl values when copying state

This fixes a bug that can result in inconsistent session-state when
copying plugin state from one plugin to another (via drag/drop
ProcessorBox::object_drop, LINK).

The underlying plugin state and settings are copied, port _shadow_data
is updated, and ::get_parameter() shows the correct new value.

However the Controllable was not updated. On Session save/restore
the value may have be lost or was inconsistently restored.
This commit is contained in:
Robin Gareus
2019-03-22 14:12:30 +01:00
parent e398656940
commit 430e51065c
2 changed files with 46 additions and 1 deletions

View File

@@ -396,6 +396,7 @@ private:
void control_list_automation_state_changed (Evoral::Parameter, AutoState);
void set_parameter_state_2X (const XMLNode& node, int version);
void set_control_ids (const XMLNode&, int version);
void update_control_values (const XMLNode&, int version);
void enable_changed ();
void bypassable_changed ();

View File

@@ -2498,7 +2498,6 @@ void
PluginInsert::set_control_ids (const XMLNode& node, int version)
{
const XMLNodeList& nlist = node.children();
for (XMLNodeConstIterator iter = nlist.begin(); iter != nlist.end(); ++iter) {
if ((*iter)->name() != Controllable::xml_node_name) {
continue;
@@ -2534,8 +2533,50 @@ PluginInsert::set_control_ids (const XMLNode& node, int version)
ac->set_state (**iter, version);
}
#endif
}
}
void
PluginInsert::update_control_values (const XMLNode& node, int version)
{
const XMLNodeList& nlist = node.children();
for (XMLNodeConstIterator iter = nlist.begin(); iter != nlist.end(); ++iter) {
if ((*iter)->name() != Controllable::xml_node_name) {
continue;
}
float val;
if (!(*iter)->get_property (X_("value"), val)) {
continue;
}
uint32_t p = (uint32_t)-1;
#ifdef LV2_SUPPORT
std::string str;
if ((*iter)->get_property (X_("symbol"), str)) {
boost::shared_ptr<LV2Plugin> lv2plugin = boost::dynamic_pointer_cast<LV2Plugin> (_plugins[0]);
if (lv2plugin) {
p = lv2plugin->port_index(str.c_str());
}
}
#endif
if (p == (uint32_t)-1) {
(*iter)->get_property (X_("parameter"), p);
}
if (p == (uint32_t)-1) {
continue;
}
/* lookup controllable */
boost::shared_ptr<Evoral::Control> c = control (Evoral::Parameter (PluginAutomation, 0, p), false);
if (!c) {
continue;
}
boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (c);
if (ac) {
ac->set_value (val, Controllable::NoGroup);
}
}
}
@@ -2667,6 +2708,9 @@ PluginInsert::set_state(const XMLNode& node, int version)
add_plugin (plugin);
create_automatable_parameters ();
set_control_ids (node, version);
} else {
/* update controllable value only (copy plugin state) */
update_control_values (node, version);
}
node.get_property ("count", count);