From 7d6e58acba17c55a6e65cad243ab74aa385beb2f Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sat, 15 Nov 2014 21:59:41 +0000 Subject: =?UTF-8?q?Improves=20the=20cmd-Q=20handler=20as=20discussed=20in?= =?UTF-8?q?=20FLTK.coredev=20"Safe=20widget=20deletion=C2=A0=C2=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10457 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index e2bf97c46..1ab0118d9 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1332,11 +1332,12 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; fl_lock_function(); NSApplicationTerminateReply reply = NSTerminateNow; 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 + Fl_Window *win = Fl::first_window(); + if (win->parent()) win = win->top_window(); + Fl_Widget_Tracker wt(win); // track the window object + Fl::handle(FL_CLOSE, win); + if (wt.exists() && win->shown()) { // the user didn't close win + reply = NSTerminateCancel; // so we return to the main program now break; } } -- cgit v1.2.3