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
This commit is contained in:
parent
1962c2b6ed
commit
d92f2d765b
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user