summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2012-08-16 20:59:36 +0000
committerMatthias Melcher <fltk@matthiasm.com>2012-08-16 20:59:36 +0000
commit590c31508196bcb444349c941bc729a8ec3f7cea (patch)
tree4ebe0751fe9082691bd34c454908669a5bc303b1 /src
parentfdb8fdfb2a57549316bad94df96b628e8fbe0c84 (diff)
STR 2730: avoid putting widgets into the delete list twice
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9666 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index d986876f9..f01ebe7c7 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1707,14 +1707,17 @@ void Fl_Window::flush() {
//#elif defined(__APPLE__)
#endif
+
//
// The following methods allow callbacks to schedule the deletion of
// widgets at "safe" times.
//
+
static int num_dwidgets = 0, alloc_dwidgets = 0;
static Fl_Widget **dwidgets = 0;
+
/**
Schedules a widget for deletion at the next call to the event loop.
Use this method to delete a widget inside a callback function.
@@ -1737,6 +1740,11 @@ static Fl_Widget **dwidgets = 0;
*/
void Fl::delete_widget(Fl_Widget *wi) {
if (!wi) return;
+
+ // don;t add the same widget twice
+ for (int i = 0; i < num_dwidgets; i++) {
+ if (dwidgets[i]==wi) return;
+ }
if (num_dwidgets >= alloc_dwidgets) {
Fl_Widget **temp;
@@ -1755,6 +1763,7 @@ void Fl::delete_widget(Fl_Widget *wi) {
num_dwidgets ++;
}
+
/**
Deletes widgets previously scheduled for deletion.
@@ -1775,10 +1784,12 @@ void 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;
+
/**
Adds a widget pointer to the widget watch list.
@@ -1843,6 +1854,7 @@ void Fl::watch_widget_pointer(Fl_Widget *&w)
#endif // DEBUG_WATCH
}
+
/**
Releases a widget pointer from the watch list.
@@ -1876,6 +1888,8 @@ void Fl::release_widget_pointer(Fl_Widget *&w)
#endif // DEBUG_WATCH
return;
}
+
+
/**
Clears a widget pointer \e in the watch list.