13
0

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
This commit is contained in:
Paul Davis 2022-02-21 15:01:36 -07:00
parent 87bcd4d83b
commit 11fd0b84b1
2 changed files with 9 additions and 6 deletions

View File

@ -77,6 +77,8 @@ TriggerUI::TriggerUI ()
, _context_menu (0) , _context_menu (0)
, _ignore_menu_action (false) , _ignore_menu_action (false)
{ {
std::cerr << "CONSTRUCT TUI " << this << std::endl;
if (follow_strings.empty()) { 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::None)));
follow_strings.push_back (follow_action_to_string (FollowAction (FollowAction::Stop))); follow_strings.push_back (follow_action_to_string (FollowAction (FollowAction::Stop)));
@ -119,6 +121,7 @@ TriggerUI::TriggerUI ()
TriggerUI::~TriggerUI() TriggerUI::~TriggerUI()
{ {
std::cerr << "DESTROY TUI " << this << std::endl;
trigger_swap_connection.disconnect (); trigger_swap_connection.disconnect ();
trigger_connections.drop_connections (); trigger_connections.drop_connections ();
} }
@ -132,8 +135,8 @@ TriggerUI::trigger_swap (uint32_t n)
} }
trigger_connections.drop_connections (); trigger_connections.drop_connections ();
trigger()->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, MISSING_INVALIDATOR, 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); trigger_changed (Properties::name);
} }
@ -846,10 +849,10 @@ TriggerUI::set_trigger (ARDOUR::TriggerReference tr)
trigger_changed (pc); trigger_changed (pc);
trigger()->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, MISSING_INVALIDATOR, 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 on_trigger_set(); //derived classes can do initialization here
} }

View File

@ -37,7 +37,7 @@ namespace Gtk
class TriggerJumpDialog; class TriggerJumpDialog;
class TriggerUI class TriggerUI : virtual public sigc::trackable
{ {
public: public:
TriggerUI (); TriggerUI ();