From a3ac93e3ace1b420318581ca0104b74b64ab6432 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 12 Sep 2008 14:09:30 +0000 Subject: [PATCH] return true from IsBeingDeleted() if any of the parent windows is marked for destruction too (see #9867) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55570 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 ++ include/wx/window.h | 2 +- interface/wx/window.h | 22 ++++++++++++++++++---- src/common/wincmn.cpp | 6 ++++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 9a8617c5d6..114b4b2000 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -385,6 +385,8 @@ All (GUI): - Show busy cursor in wxLaunchDefaultBrowser and add wxBROWSER_NOBUSYCURSOR. - Added wxFlexGridSizer::Is{Row,Col}Growable() (Marcin Wojdyr). - Added "enabled" and "hidden" attributes to radio box items in XRC. +- wxWindow::IsBeingDeleted() now returns true not only if the window itself is + marked for destruction but also if any of its parent windows are. wxGTK: diff --git a/include/wx/window.h b/include/wx/window.h index 59e9eabda4..268fee782e 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -199,7 +199,7 @@ public: bool DestroyChildren(); // is the window being deleted? - bool IsBeingDeleted() const { return m_isBeingDeleted; } + bool IsBeingDeleted() const; // window attributes // ----------------- diff --git a/interface/wx/window.h b/interface/wx/window.h index b7b8b22875..37998c275f 100644 --- a/interface/wx/window.h +++ b/interface/wx/window.h @@ -126,7 +126,7 @@ @library{wxcore} @category{FIXME} - @see @ref overview_eventhandling "Event handling overview", + @see @ref overview_eventhandling "Event handling overview", @ref overview_windowsizing "Window sizing overview" */ class wxWindow : public wxEvtHandler @@ -136,7 +136,7 @@ public: Default constructor */ wxWindow(); - + /** Constructs a window, which can be a child of a frame, dialog or any other non-control window. @@ -202,7 +202,7 @@ public: container windows */ virtual bool AcceptsFocusRecursively() const; - + /** Adds a child window. This is called automatically by window creation functions so should not be required by the application programmer. @@ -439,6 +439,20 @@ public: */ virtual void DestroyChildren(); + /** + Returns true if this window is in process of being destroyed. + + The top level windows are not deleted immediately but are rather + scheduled for later destruction to give them time to process any + pending messages, see Destroy() description. + + This function returns @true if this window, or one of its parent + windows, is scheduled for destruction and can be useful to avoid + manipulating it as it's usually useless to do something with a window + which is on the point of disappearing anyhow. + */ + bool IsBeingDeleted() const; + /** Disables the window. Same as @ref Enable() Enable(@false). @@ -517,7 +531,7 @@ public: it matches itself. */ wxWindow* FindWindow(long id) const; - + /** Find a child of this window, by name. May return @a this if diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index c40aa1d746..1a70ba6887 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -379,6 +379,12 @@ wxWindowBase::~wxWindowBase() #endif } +bool wxWindowBase::IsBeingDeleted() const +{ + return m_isBeingDeleted || + (!IsTopLevel() && m_parent && m_parent->IsBeingDeleted()); +} + void wxWindowBase::SendDestroyEvent() { wxWindowDestroyEvent event; -- 2.45.2