Author: manolo
Date: 2011-11-22 06:48:47 -0800 (Tue, 22 Nov 2011)
New Revision: 9182
Log:
Mac OS: fix possible crash when closing window with a callback that deletes it.

Modified:
   branches/branch-1.3/src/Fl_cocoa.mm

Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2011-11-22 12:33:49 UTC (rev 9181)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2011-11-22 14:48:47 UTC (rev 9182)
@@ -590,10 +590,12 @@
 - (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 @@
   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;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to