Binding Proxy: Drop references as requested.
authorRobin Gareus <robin@gareus.org>
Sun, 30 Jul 2017 00:40:45 +0000 (02:40 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 30 Jul 2017 00:42:55 +0000 (02:42 +0200)
libs/widgets/binding_proxy.cc
libs/widgets/widgets/binding_proxy.h

index 666797a0eb36f70ed9a368beacedc54c4cbba869..85119ab1c0876d5a3cec677e55d77b89fdb6b387 100644 (file)
@@ -20,6 +20,7 @@
 #include <iostream>
 
 #include "pbd/controllable.h"
+#include "gtkmm2ext/gui_thread.h"
 #include "gtkmm2ext/keyboard.h"
 #include "widgets/binding_proxy.h"
 #include "widgets/popup.h"
@@ -38,6 +39,12 @@ BindingProxy::BindingProxy (boost::shared_ptr<Controllable> c)
        : prompter (0),
          controllable (c)
 {
+       if (c) {
+               c->DropReferences.connect (
+                               _controllable_going_away_connection, invalidator (*this),
+                               boost::bind (&BindingProxy::set_controllable, this, boost::shared_ptr<Controllable> ()),
+                               gui_context());
+       }
 }
 
 BindingProxy::BindingProxy ()
@@ -57,6 +64,14 @@ BindingProxy::set_controllable (boost::shared_ptr<Controllable> c)
 {
        learning_finished ();
        controllable = c;
+
+       _controllable_going_away_connection.disconnect ();
+       if (c) {
+               c->DropReferences.connect (
+                               _controllable_going_away_connection, invalidator (*this),
+                               boost::bind (&BindingProxy::set_controllable, this, boost::shared_ptr<Controllable> ()),
+                               gui_context());
+       }
 }
 
 void
index 8ac49edb9f1cd240d8abe5985a06df9ac2805393..4d5051382d83027b37c34b905eb9260a78fc7cb5 100644 (file)
@@ -59,6 +59,7 @@ protected:
        static guint bind_statemask;
 
        PBD::ScopedConnection learning_connection;
+       PBD::ScopedConnection _controllable_going_away_connection;
        void learning_finished ();
        bool prompter_hiding (GdkEventAny *);
 };