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
This commit is contained in:
Matthias Melcher 2012-08-16 20:59:36 +00:00
parent fdb8fdfb2a
commit 590c315081
1 changed files with 14 additions and 0 deletions

View File

@ -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.