X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fslavable_automation_control.cc;h=d4002343e881e48909eb37e7c54b0da16e00d4a4;hb=91ab5e31751105d59386aab6a6e16ac5582904dc;hp=8c50863d954235c0a6f67fd7498d5ad9b8fc74cc;hpb=51064f77a874f15c2cebd4fed12996177f951936;p=ardour.git diff --git a/libs/ardour/slavable_automation_control.cc b/libs/ardour/slavable_automation_control.cc index 8c50863d95..d4002343e8 100644 --- a/libs/ardour/slavable_automation_control.cc +++ b/libs/ardour/slavable_automation_control.cc @@ -139,10 +139,18 @@ SlavableAutomationControl::add_master (boost::shared_ptr m) itself. */ - m->DropReferences.connect_same_thread (masters_connections, boost::bind (&SlavableAutomationControl::master_going_away, this, m)); + m->DropReferences.connect_same_thread (masters_connections, boost::bind (&SlavableAutomationControl::master_going_away, this, boost::weak_ptr(m))); - /* Store the connection inside the MasterRecord, so that when we destroy it, the connection is destroyed - and we no longer hear about changes to the AutomationControl. + /* Store the connection inside the MasterRecord, so + that when we destroy it, the connection is destroyed + and we no longer hear about changes to the + AutomationControl. + + Note that this also makes it safe to store a + boost::shared_ptr in the functor, + since we know we will destroy the functor when the + connection is destroyed, which happens when we + disconnect from the master (for any reason). Note that we fix the "from_self" argument that will be given to our own Changed signal to "false", @@ -246,13 +254,18 @@ SlavableAutomationControl::remove_master (boost::shared_ptr m Glib::Threads::RWLock::WriterLock lm (master_lock); current_value = get_value_locked (); erased = _masters.erase (m->id()); - if (erased) { + if (erased && !_session.deletion_in_progress()) { recompute_masters_ratios (current_value); } masters_left = _masters.size (); new_value = get_value_locked (); } + if (_session.deletion_in_progress()) { + /* no reason to care about new values or sending signals */ + return; + } + if (erased) { MasterStatusChange (); /* EMIT SIGNAL */ }