From d92f2d765b770fcc1c88e1bdcd887bf261376f52 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 22 Nov 2011 14:48:47 +0000 Subject: 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 --- src/Fl_cocoa.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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; -- cgit v1.2.3