From edcfa23e14d968605bd5f07ae6b0793229f11f2c Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 30 Jul 2017 02:40:45 +0200 Subject: [PATCH] Binding Proxy: Drop references as requested. --- libs/widgets/binding_proxy.cc | 15 +++++++++++++++ libs/widgets/widgets/binding_proxy.h | 1 + 2 files changed, 16 insertions(+) diff --git a/libs/widgets/binding_proxy.cc b/libs/widgets/binding_proxy.cc index 666797a0eb..85119ab1c0 100644 --- a/libs/widgets/binding_proxy.cc +++ b/libs/widgets/binding_proxy.cc @@ -20,6 +20,7 @@ #include #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 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 ()), + gui_context()); + } } BindingProxy::BindingProxy () @@ -57,6 +64,14 @@ BindingProxy::set_controllable (boost::shared_ptr 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 ()), + gui_context()); + } } void diff --git a/libs/widgets/widgets/binding_proxy.h b/libs/widgets/widgets/binding_proxy.h index 8ac49edb9f..4d5051382d 100644 --- a/libs/widgets/widgets/binding_proxy.h +++ b/libs/widgets/widgets/binding_proxy.h @@ -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 *); };