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.
This commit is contained in:
parent
474d68c051
commit
9ccc56e162
@ -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));
|
_button->signal_toggled().connect (sigc::mem_fun (*this, &CheckOption::toggled));
|
||||||
|
|
||||||
Gtkmm2ext::Activatable::set_related_action (act);
|
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);
|
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
|
||||||
if (tact) {
|
if (tact) {
|
||||||
action_toggled ();
|
action_toggled ();
|
||||||
tact->signal_toggled().connect (sigc::mem_fun (*this, &CheckOption::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));
|
_action->connect_property_changed ("sensitive", sigc::mem_fun (*this, &CheckOption::action_sensitivity_changed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckOption::~CheckOption ()
|
||||||
|
{
|
||||||
|
_callback_connection.disconnect ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -193,6 +193,7 @@ class CheckOption : public OptionEditorComponent , public Gtkmm2ext::Activatable
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CheckOption (std::string const &, std::string const &, Glib::RefPtr<Gtk::Action> act );
|
CheckOption (std::string const &, std::string const &, Glib::RefPtr<Gtk::Action> act );
|
||||||
|
virtual ~CheckOption ();
|
||||||
void set_state_from_config () {}
|
void set_state_from_config () {}
|
||||||
void parameter_changed (std::string const &) {}
|
void parameter_changed (std::string const &) {}
|
||||||
void add_to_page (OptionEditorPage*);
|
void add_to_page (OptionEditorPage*);
|
||||||
@ -203,17 +204,18 @@ public:
|
|||||||
|
|
||||||
Gtk::Widget& tip_widget() { return *_button; }
|
Gtk::Widget& tip_widget() { return *_button; }
|
||||||
|
|
||||||
|
protected:
|
||||||
void action_toggled ();
|
void action_toggled ();
|
||||||
void action_sensitivity_changed () {}
|
void action_sensitivity_changed () {}
|
||||||
void action_visibility_changed () {}
|
void action_visibility_changed () {}
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void toggled ();
|
virtual void toggled ();
|
||||||
|
|
||||||
sigc::slot<bool> _get; ///< slot to get the configuration variable's value
|
|
||||||
sigc::slot<bool, bool> _set; ///< slot to set the configuration variable's value
|
|
||||||
Gtk::CheckButton* _button; ///< UI button
|
Gtk::CheckButton* _button; ///< UI button
|
||||||
Gtk::Label* _label; ///< label for button, so we can use markup
|
Gtk::Label* _label; ///< label for button, so we can use markup
|
||||||
|
|
||||||
|
private:
|
||||||
|
sigc::connection _callback_connection;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Component which provides the UI to handle a boolean option using a GTK CheckButton */
|
/** Component which provides the UI to handle a boolean option using a GTK CheckButton */
|
||||||
|
Loading…
Reference in New Issue
Block a user