diff --git a/libs/ardour/ardour/slavable.h b/libs/ardour/ardour/slavable.h index 83675f0e22..5af954d51c 100644 --- a/libs/ardour/ardour/slavable.h +++ b/libs/ardour/ardour/slavable.h @@ -52,6 +52,8 @@ class LIBARDOUR_API Slavable void assign (boost::shared_ptr); void unassign (boost::shared_ptr); + PBD::Signal2,bool> AssignmentChange; + virtual boost::shared_ptr automation_control (const Evoral::Parameter& id) = 0; static std::string xml_node_name; diff --git a/libs/ardour/slavable.cc b/libs/ardour/slavable.cc index 10eb084372..61a11f257d 100644 --- a/libs/ardour/slavable.cc +++ b/libs/ardour/slavable.cc @@ -117,19 +117,23 @@ void Slavable::assign (boost::shared_ptr v) { assert (v); - Glib::Threads::RWLock::WriterLock lm (master_lock); - if (assign_controls (v) == 0) { - _masters.insert (v->number()); + { + Glib::Threads::RWLock::WriterLock lm (master_lock); + if (assign_controls (v) == 0) { + _masters.insert (v->number()); + } + + /* Do NOT use ::unassign() because it will store a + * boost::shared_ptr in the functor, leaving a dangling ref to the + * VCA. + */ + + + v->Drop.connect_same_thread (unassign_connections, boost::bind (&Slavable::weak_unassign, this, boost::weak_ptr(v))); + v->DropReferences.connect_same_thread (unassign_connections, boost::bind (&Slavable::weak_unassign, this, boost::weak_ptr(v))); } - /* Do NOT use ::unassign() because it will store a - * boost::shared_ptr in the functor, leaving a dangling ref to the - * VCA. - */ - - - v->Drop.connect_same_thread (unassign_connections, boost::bind (&Slavable::weak_unassign, this, boost::weak_ptr(v))); - v->DropReferences.connect_same_thread (unassign_connections, boost::bind (&Slavable::weak_unassign, this, boost::weak_ptr(v))); + AssignmentChange (v, true); } void @@ -144,13 +148,17 @@ Slavable::weak_unassign (boost::weak_ptr v) void Slavable::unassign (boost::shared_ptr v) { - Glib::Threads::RWLock::WriterLock lm (master_lock); - (void) unassign_controls (v); - if (v) { - _masters.erase (v->number()); - } else { - _masters.clear (); + { + Glib::Threads::RWLock::WriterLock lm (master_lock); + + (void) unassign_controls (v); + if (v) { + _masters.erase (v->number()); + } else { + _masters.clear (); + } } + AssignmentChange (v, false); } /* Gain, solo & mute are currently the only controls that are