summaryrefslogtreecommitdiff
path: root/src/Fl_Menu_Button.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2006-04-27 21:40:47 +0000
committerMatthias Melcher <fltk@matthiasm.com>2006-04-27 21:40:47 +0000
commitad0fc9ca23717b46639d2f28a83437300499870d (patch)
tree80502551cd9ec6701c76c5942a8bd6466376f945 /src/Fl_Menu_Button.cxx
parentcbbec03b5e44e8855dbcf424150be5e144044fb2 (diff)
STR #1162: Fl_Menu_Button::popup was trying to access a previously deleted widget (itself). The delayed deleting mechanism in 'Fl::delete_widget' did not work in this case because the main loop is called before the callback returns. The fix implements a type of automatic pointer that will be cleared to NULL should the widget get deleted. This may not be a 'nice' solution, but it does fix the problem reliably. We could actually use this for all widget pointers and remove the delayed delete mechanism alltogether
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5037 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Menu_Button.cxx')
-rw-r--r--src/Fl_Menu_Button.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Fl_Menu_Button.cxx b/src/Fl_Menu_Button.cxx
index 80768a6e0..a3c13a829 100644
--- a/src/Fl_Menu_Button.cxx
+++ b/src/Fl_Menu_Button.cxx
@@ -51,6 +51,8 @@ const Fl_Menu_Item* Fl_Menu_Button::popup() {
const Fl_Menu_Item* m;
pressed_menu_button_ = this;
redraw();
+ Fl_Widget *mb = this;
+ Fl::watch_widget_pointer(mb);
if (!box() || type()) {
m = menu()->popup(Fl::event_x(), Fl::event_y(), label(), mvalue(), this);
} else {
@@ -58,7 +60,8 @@ const Fl_Menu_Item* Fl_Menu_Button::popup() {
}
picked(m);
pressed_menu_button_ = 0;
- redraw();
+ if (mb) mb->redraw();
+ Fl::release_widget_pointer(mb);
return m;
}