diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl.cxx | 47 | ||||
| -rw-r--r-- | src/Fl_Menu_Button.cxx | 5 | ||||
| -rw-r--r-- | src/Fl_Widget.cxx | 1 |
3 files changed, 52 insertions, 1 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index c9dcd0a6c..72ea71414 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1207,6 +1207,53 @@ Fl::do_widget_deletion() { num_dwidgets = 0; } +static Fl_Widget ***widget_watch = 0; +static int num_widget_watch = 0; +static int max_widget_watch = 0; + +void Fl::watch_widget_pointer(Fl_Widget *&w) +{ + Fl_Widget **wp = &w; + int i; + for (i=0; i<num_widget_watch; ++i) { + if (widget_watch[i]==wp) return; + } + for (i=0; i<num_widget_watch; ++i) { + if (widget_watch[i]==0L) { + widget_watch[i] = wp; + return; + } + } + if (num_widget_watch==max_widget_watch) { + max_widget_watch += 8; + widget_watch = (Fl_Widget***)realloc(widget_watch, sizeof(Fl_Widget**)*max_widget_watch); + } + widget_watch[num_widget_watch++] = wp; +} + +void Fl::release_widget_pointer(Fl_Widget *&w) +{ + Fl_Widget **wp = &w; + int i; + for (i=0; i<num_widget_watch; ++i) { + if (widget_watch[i]==wp) { + widget_watch[i] = 0L; + return; + } + } +} + +void Fl::clear_widget_pointer(Fl_Widget const *w) +{ + if (w==0L) return; + int i; + for (i=0; i<num_widget_watch; ++i) { + if (widget_watch[i] && *widget_watch[i]==w) { + *widget_watch[i] = 0L; + } + } +} + // // End of "$Id$". 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; } diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 3c637767b..9f33b2cf3 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -133,6 +133,7 @@ extern void fl_throw_focus(Fl_Widget*); // in Fl_x.cxx // However, it is only legal to destroy a "root" such as an Fl_Window, // and automatic destructors may be called. Fl_Widget::~Fl_Widget() { + Fl::clear_widget_pointer(this); if (flags() & COPIED_LABEL) free((void *)(label_.value)); parent_ = 0; // Don't throw focus to a parent widget. fl_throw_focus(this); |
