]> git.saurik.com Git - wxWidgets.git/commitdiff
handle child destruction notifications in wxTLW itself and reset both normal and...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 6 Apr 2007 19:22:38 +0000 (19:22 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 6 Apr 2007 19:22:38 +0000 (19:22 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45275 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/toplevel.h
src/common/toplvcmn.cpp
src/common/wincmn.cpp

index 98c2bd6b491ace60761d493af82a3387a966c542..a4530bd2b8a0174180ea76bdc10430351a0d3a92 100644 (file)
@@ -295,6 +295,11 @@ protected:
     static int WidthDefault(int w) { return w == wxDefaultCoord ? GetDefaultSize().x : w; }
     static int HeightDefault(int h) { return h == wxDefaultCoord ? GetDefaultSize().y : h; }
 
+    // reset m_winDefault and m_winTmpDefault if they point to the window being
+    // destroyed
+    void OnChildDestroy(wxWindowDestroyEvent& event);
+
+
     // the frame icon
     wxIconBundle m_icons;
 
index f090433b4019f7464c55b80bafa3a5ffaf3688eb..433e3a6aae7b2e7fec5560771a20ac7264b5197c 100644 (file)
@@ -39,6 +39,7 @@
 BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow)
     EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow)
     EVT_SIZE(wxTopLevelWindowBase::OnSize)
+    EVT_WINDOW_DESTROY(wxTopLevelWindowBase::OnChildDestroy)
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -369,6 +370,17 @@ void wxTopLevelWindowBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
     Destroy();
 }
 
+void wxTopLevelWindowBase::OnChildDestroy(wxWindowDestroyEvent& event)
+{
+    event.Skip();
+
+    wxWindow * const win = event.GetWindow();
+    if ( win == m_winDefault )
+        m_winDefault = NULL;
+    if ( win == m_winTmpDefault )
+        m_winTmpDefault = NULL;
+}
+
 bool wxTopLevelWindowBase::SendIconizeEvent(bool iconized)
 {
     wxIconizeEvent event(GetId(), iconized);
index 49417dbaf7eb3fc0224210ac25118cda887181c9..65a8be784cdc4cfb1ab74047ae4e2069b0932b3e 100644 (file)
@@ -318,23 +318,9 @@ wxWindowBase::~wxWindowBase()
 
     wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
 
-    // reset the top-level parent's default item if it is this widget
+    // notify the parent about this window destruction
     if ( m_parent )
-    {
-        wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this),
-                                              wxTopLevelWindow);
-
-        if ( tlw && tlw->GetDefaultItem() == this )
-            tlw->SetDefaultItem(NULL);
-        if ( tlw && tlw->GetTmpDefaultItem() == this )
-            tlw->SetTmpDefaultItem(NULL);
-    }
-
-    // reset the dangling pointer our parent window may keep to us
-    if ( m_parent )
-    {
         m_parent->RemoveChild(this);
-    }
 
 #if wxUSE_CARET
     delete m_caret;