From 80bd905981c1d010d168057781073c45f4321dc6 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sat, 15 Nov 2014 15:23:56 +0000 Subject: Fl::delete_widget() now hides a widget/window if it is shown (visible_r()). This is useful (necessary) because in old (pre 1.1.6) which didn't have Fl::delete_widget() users would have called 'delete window', which would have hidden a window and destroyed it as well. Now the widget/window is hidden immediately, whereas it is destroyed delayed, which comes much closer to the previous behavior and is useful for better window close detection in Mac OS X cmd-Q handling. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10456 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Fl.cxx b/src/Fl.cxx index a08b095ec..36b0e54ed 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1865,7 +1865,13 @@ static Fl_Widget **dwidgets = 0; When deleting groups or windows, you must only delete the group or window widget and not the individual child widgets. - \since FLTK 1.3 it is not necessary to remove widgets from their parent + \since FLTK 1.3.4 the widget will be hidden immediately, but the actual + destruction will be delayed until the event loop is finished. Up to + FLTK 1.3.3 windows wouldn't be hidden before the event loop was done, + hence you had to hide() a window in your window close callback if + you called Fl::delete_widget() to destroy (and hide) the window. + + \since FLTK 1.3.0 it is not necessary to remove widgets from their parent groups or windows before calling this, because it will be done in the widget's destructor, but it is not a failure to do this nevertheless. @@ -1876,8 +1882,11 @@ static Fl_Widget **dwidgets = 0; */ void Fl::delete_widget(Fl_Widget *wi) { if (!wi) return; - - // don;t add the same widget twice + + // if the widget is shown(), hide() it (FLTK 1.3.4) + if (wi->visible_r()) wi->hide(); + + // don't add the same widget twice to the widget delete list for (int i = 0; i < num_dwidgets; i++) { if (dwidgets[i]==wi) return; } -- cgit v1.2.3