diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2014-11-15 15:23:56 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2014-11-15 15:23:56 +0000 |
| commit | 80bd905981c1d010d168057781073c45f4321dc6 (patch) | |
| tree | 9273e30ac68228e4960bce40b71aaea365c4d52a | |
| parent | cc9b73d97a9aeca522d08e0e4dfcac757dcc0e3d (diff) | |
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
| -rw-r--r-- | CHANGES | 16 | ||||
| -rw-r--r-- | src/Fl.cxx | 15 |
2 files changed, 21 insertions, 10 deletions
@@ -2,15 +2,17 @@ CHANGES IN FLTK 1.3.4 RELEASED: ??? ?? ???? New features and extensions - - added full support of true subwindows to the Mac OS X FLTK platform. Window - nesting to any depth is possible. An Fl_Gl_Window window or subwindow - can contain Fl_Window's as subwindows. + - added full support of true subwindows to the Mac OS X FLTK platform. + Window nesting to any depth is possible. An Fl_Gl_Window window or + subwindow can contain Fl_Window's as subwindows. - Other improvements + Other improvements - - fl_read_image() now captures all pixels within the rectangle described - by its arguments, whether they belong to a GL scene or not (STR #3142). It also - captures subwindows of GL windows. + - fl_read_image() now captures all pixels within the rectangle + described by its arguments, whether they belong to a GL scene + or not (STR #3142). It also captures subwindows of GL windows. + - Fl::delete_widget() now hides the widget or window immediately + (i.e. when called) - only destruction is delayed as before. CHANGES IN FLTK 1.3.3 RELEASED: Nov 03 2014 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; } |
