From 11fd0b84b153bdc18cfdb470bc97c8f7b315356e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 21 Feb 2022 15:01:36 -0700 Subject: [PATCH] derive TriggerUI from sigc::trackable so that it can be automically disconnected from signals The explicit disconnect in the destructor prevents any more signal->connection firing, but the invalidator is required to remove existing queued slot calls in the receiving thread --- gtk2_ardour/trigger_ui.cc | 13 ++++++++----- gtk2_ardour/trigger_ui.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/trigger_ui.cc b/gtk2_ardour/trigger_ui.cc index 82ade283a1..1fd0dc0a2d 100644 --- a/gtk2_ardour/trigger_ui.cc +++ b/gtk2_ardour/trigger_ui.cc @@ -77,6 +77,8 @@ TriggerUI::TriggerUI () , _context_menu (0) , _ignore_menu_action (false) { + std::cerr << "CONSTRUCT TUI " << this << std::endl; + if (follow_strings.empty()) { follow_strings.push_back (follow_action_to_string (FollowAction (FollowAction::None))); follow_strings.push_back (follow_action_to_string (FollowAction (FollowAction::Stop))); @@ -119,6 +121,7 @@ TriggerUI::TriggerUI () TriggerUI::~TriggerUI() { + std::cerr << "DESTROY TUI " << this << std::endl; trigger_swap_connection.disconnect (); trigger_connections.drop_connections (); } @@ -132,8 +135,8 @@ TriggerUI::trigger_swap (uint32_t n) } trigger_connections.drop_connections (); - trigger()->PropertyChanged.connect (trigger_connections, MISSING_INVALIDATOR, boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ()); - tref.box->PropertyChanged.connect (trigger_connections, MISSING_INVALIDATOR, boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ()); + trigger()->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ()); + tref.box->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ()); trigger_changed (Properties::name); } @@ -846,10 +849,10 @@ TriggerUI::set_trigger (ARDOUR::TriggerReference tr) trigger_changed (pc); - trigger()->PropertyChanged.connect (trigger_connections, MISSING_INVALIDATOR, boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context()); - tref.box->PropertyChanged.connect (trigger_connections, MISSING_INVALIDATOR, boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ()); + trigger()->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context()); + tref.box->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ()); - tref.box->TriggerSwapped.connect (trigger_swap_connection, MISSING_INVALIDATOR, boost::bind (&TriggerUI::trigger_swap, this, _1), gui_context ()); + tref.box->TriggerSwapped.connect (trigger_swap_connection, invalidator (*this), boost::bind (&TriggerUI::trigger_swap, this, _1), gui_context ()); on_trigger_set(); //derived classes can do initialization here } diff --git a/gtk2_ardour/trigger_ui.h b/gtk2_ardour/trigger_ui.h index dc2bcbae10..bf62bb1f24 100644 --- a/gtk2_ardour/trigger_ui.h +++ b/gtk2_ardour/trigger_ui.h @@ -37,7 +37,7 @@ namespace Gtk class TriggerJumpDialog; -class TriggerUI +class TriggerUI : virtual public sigc::trackable { public: TriggerUI ();