From 96febb8f266e7dad8b6426b7dd0d7ebc3d6e87c7 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 21 Jun 2021 19:59:40 +0200 Subject: [PATCH] Properly solve d'tor order (controllable first) #8756 --- libs/ardour/plugin_insert.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index b0048bbd01..1d91bc76be 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -121,6 +121,21 @@ PluginInsert::drop_references () for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { (*i)->drop_references (); } + + /* PluginInsert::_plugins must exist until PBD::Controllable + * has emitted drop_references. This is because + * AC::get_value() calls _plugin[0]->get_parameter(..) + * + * Usually ~Automatable, calls drop_references for each + * controllable, but that runs after ~PluginInsert. + */ + { + Glib::Threads::Mutex::Lock lm (_control_lock); + for (Controls::const_iterator li = _controls.begin(); li != _controls.end(); ++li) { + boost::dynamic_pointer_cast(li->second)->drop_references (); + } + _controls.clear (); + } Processor::drop_references (); }