From ff09e7237c0ccbab0855d2da87d392810dab69c5 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 30 Oct 2010 16:50:44 +0000 Subject: Fl_Button shortcut handling would crash if the widget was deleted in the callback. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7774 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Button.cxx | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'src/Fl_Button.cxx') diff --git a/src/Fl_Button.cxx b/src/Fl_Button.cxx index 23b974039..167f5287c 100644 --- a/src/Fl_Button.cxx +++ b/src/Fl_Button.cxx @@ -128,22 +128,9 @@ int Fl_Button::handle(int event) { return 1; case FL_SHORTCUT: if (!(shortcut() ? - Fl::test_shortcut(shortcut()) : test_shortcut())) return 0; - + Fl::test_shortcut(shortcut()) : test_shortcut())) return 0; if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this); - - if (type() == FL_RADIO_BUTTON && !value_) { - setonly(); - set_changed(); - if (when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE) ) - do_callback(); - } else if (type() == FL_TOGGLE_BUTTON) { - value(!value()); - set_changed(); - if (when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE)) - do_callback(); - } else if (when() & FL_WHEN_RELEASE) do_callback(); - return 1; + goto triggered_by_keyboard; case FL_FOCUS : /* FALLTHROUGH */ case FL_UNFOCUS : if (Fl::visible_focus()) { @@ -161,6 +148,7 @@ int Fl_Button::handle(int event) { if (Fl::focus() == this && Fl::event_key() == ' ' && !(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META))) { set_changed(); + triggered_by_keyboard: Fl_Widget_Tracker wp(this); if (type() == FL_RADIO_BUTTON && !value_) { setonly(); -- cgit v1.2.3