diff options
author | Robin Gareus <robin@gareus.org> | 2018-12-08 21:18:54 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2018-12-08 21:18:54 +0100 |
commit | 9ccc56e162554c292b25408246e3680b8f14eea7 (patch) | |
tree | 0d30b6978eb59494e1faaaa794300f336e44e8dd /gtk2_ardour/option_editor.cc | |
parent | 474d68c05132291fd8eb200006e7e63aebefdc8d (diff) |
Fix CheckOption crash on session-reload
The ToggleAction has a lifetime of the UI, independent of the
CheckOption widget. The CheckOption needs to unsubscribe from the
signal_toggled() signal when it is deleted.
Also a CheckOption without a Action makes no sense. require _action
to be give at instantiation time.
Diffstat (limited to 'gtk2_ardour/option_editor.cc')
-rw-r--r-- | gtk2_ardour/option_editor.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index 875e611452..3482f66980 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -213,18 +213,22 @@ CheckOption::CheckOption (string const & i, string const & n, Glib::RefPtr<Gtk:: _button->signal_toggled().connect (sigc::mem_fun (*this, &CheckOption::toggled)); Gtkmm2ext::Activatable::set_related_action (act); - if (_action) { + assert (_action); - action_sensitivity_changed (); + action_sensitivity_changed (); - Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action); - if (tact) { - action_toggled (); - tact->signal_toggled().connect (sigc::mem_fun (*this, &CheckOption::action_toggled)); - } - - _action->connect_property_changed ("sensitive", sigc::mem_fun (*this, &CheckOption::action_sensitivity_changed)); + Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action); + if (tact) { + action_toggled (); + _callback_connection = tact->signal_toggled().connect (sigc::mem_fun (*this, &CheckOption::action_toggled)); } + + _action->connect_property_changed ("sensitive", sigc::mem_fun (*this, &CheckOption::action_sensitivity_changed)); +} + +CheckOption::~CheckOption () +{ + _callback_connection.disconnect (); } void |