summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2011-11-22 14:48:47 +0000
committerManolo Gouy <Manolo>2011-11-22 14:48:47 +0000
commitd92f2d765b770fcc1c88e1bdcd887bf261376f52 (patch)
tree965fe6a904bc7d6556ab9582fd57fc80a62009c8 /src
parent1962c2b6edaedaaeb43f5428c22e1243ccf52d94 (diff)
Mac OS: fix possible crash when closing window with a callback that deletes it.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9182 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 943a45c3d..7e6ac9517 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -590,10 +590,12 @@ static void do_timer(CFRunLoopTimerRef timer, void* data)
- (BOOL)windowShouldClose:(FLWindow *)fl
{
fl_lock_function();
- Fl::handle( FL_CLOSE, [fl getFl_Window] ); // this might or might not close the window
+ Fl_Window *to_close = [fl getFl_Window];
+ Fl::handle( FL_CLOSE, to_close ); // this might or might not close the window
+ Fl::do_widget_deletion();
if (!Fl_X::first) return YES;
Fl_Window *l = Fl::first_window();
- while( l != NULL && l != [fl getFl_Window]) l = Fl::next_window(l);
+ while( l != NULL && l != to_close) l = Fl::next_window(l);
fl_unlock_function();
return (l == NULL ? YES : NO);
}
@@ -1027,6 +1029,7 @@ void fl_open_callback(void (*cb)(const char *)) {
while ( Fl_X::first ) {
Fl_X *x = Fl_X::first;
Fl::handle( FL_CLOSE, x->w );
+ Fl::do_widget_deletion();
if ( Fl_X::first == x ) {
reply = NSTerminateCancel; // FLTK has not closed all windows, so we return to the main program now
break;