From 8e35ab96f64a0ad21470043492e0153980b95382 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 15 Sep 2003 11:45:08 +0000 Subject: [PATCH] call RemoveChild() in ~wxWindowBase instead of doing it in each ~wxWindow for each port git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/cocoa/window.mm | 3 --- src/common/wincmn.cpp | 21 +++++++++++---------- src/gtk/window.cpp | 3 --- src/gtk1/window.cpp | 3 --- src/mac/carbon/window.cpp | 7 ------- src/mac/window.cpp | 7 ------- src/mgl/window.cpp | 6 ------ src/motif/window.cpp | 3 --- src/msw/window.cpp | 3 --- src/os2/window.cpp | 3 --- src/x11/window.cpp | 3 --- 11 files changed, 11 insertions(+), 51 deletions(-) diff --git a/src/cocoa/window.mm b/src/cocoa/window.mm index 0b0bb5ede7..8412232abb 100644 --- a/src/cocoa/window.mm +++ b/src/cocoa/window.mm @@ -281,9 +281,6 @@ wxWindow::~wxWindow() wxAutoNSAutoreleasePool pool; DestroyChildren(); - if(m_parent) - m_parent->RemoveChild(this); - CocoaRemoveFromParent(); delete m_cocoaHider; delete m_cocoaScroller; diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 2961a758e9..7c03f1178d 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -266,6 +266,17 @@ wxWindowBase::~wxWindowBase() wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") ); + // reset the dangling pointer our parent window may keep to us + if ( m_parent ) + { + if ( m_parent->GetDefaultItem() == this ) + { + m_parent->SetDefaultItem(NULL); + } + + m_parent->RemoveChild(this); + } + #if wxUSE_CARET delete m_caret; #endif // wxUSE_CARET @@ -305,12 +316,6 @@ wxWindowBase::~wxWindowBase() #if wxUSE_ACCESSIBILITY delete m_accessible; #endif - - // reset the dangling pointer our parent window may keep to us - if ( m_parent && m_parent->GetDefaultItem() == this ) - { - m_parent->SetDefaultItem(NULL); - } } bool wxWindowBase::Destroy() @@ -343,10 +348,6 @@ bool wxWindowBase::DestroyChildren() wxWindow *child = node->GetData(); - wxASSERT_MSG( child, wxT("children list contains empty nodes") ); - - child->Show(FALSE); - child->Destroy(); wxASSERT_MSG( !GetChildren().Find(child), diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 5dd7c8aabc..01febc0b4a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2667,9 +2667,6 @@ wxWindowGTK::~wxWindowGTK() DestroyChildren(); - if (m_parent) - m_parent->RemoveChild( this ); - #ifdef HAVE_XIM if (m_ic) gdk_ic_destroy (m_ic); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 5dd7c8aabc..01febc0b4a 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2667,9 +2667,6 @@ wxWindowGTK::~wxWindowGTK() DestroyChildren(); - if (m_parent) - m_parent->RemoveChild( this ); - #ifdef HAVE_XIM if (m_ic) gdk_ic_destroy (m_ic); diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 701f4010ec..86f4af777c 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -174,15 +174,8 @@ wxWindowMac::~wxWindowMac() gFocusWindow = NULL ; } - // CS: copied from MSW : - // VS: destroy children first and _then_ detach *this from its parent. - // If we'd do it the other way around, children wouldn't be able - // find their parent frame (see above). DestroyChildren(); - if ( m_parent ) - m_parent->RemoveChild(this); - // delete our drop target if we've got one #if wxUSE_DRAG_AND_DROP if ( m_dropTarget != NULL ) diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 701f4010ec..86f4af777c 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -174,15 +174,8 @@ wxWindowMac::~wxWindowMac() gFocusWindow = NULL ; } - // CS: copied from MSW : - // VS: destroy children first and _then_ detach *this from its parent. - // If we'd do it the other way around, children wouldn't be able - // find their parent frame (see above). DestroyChildren(); - if ( m_parent ) - m_parent->RemoveChild(this); - // delete our drop target if we've got one #if wxUSE_DRAG_AND_DROP if ( m_dropTarget != NULL ) diff --git a/src/mgl/window.cpp b/src/mgl/window.cpp index 24d5ec98a8..75f3a09ffe 100644 --- a/src/mgl/window.cpp +++ b/src/mgl/window.cpp @@ -591,14 +591,8 @@ wxWindowMGL::~wxWindowMGL() if ( gs_windowUnderMouse == this ) gs_windowUnderMouse = NULL; - // VS: destroy children first and _then_ detach *this from its parent. - // If we'd do it the other way around, children wouldn't be able - // find their parent frame (see above). DestroyChildren(); - if ( m_parent ) - m_parent->RemoveChild(this); - if ( m_wnd ) MGL_wmDestroyWindow(m_wnd); } diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 6b87a729e1..63b1e37a52 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -374,9 +374,6 @@ wxWindow::~wxWindow() DetachWidget(wMain); } - if ( m_parent ) - m_parent->RemoveChild( this ); - // If m_drawingArea, we're a fully-fledged window with drawing area, // scrollbars etc. (what wxCanvas used to be) if ( m_drawingArea ) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index c1be9a6860..598b077b1a 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -520,9 +520,6 @@ wxWindowMSW::~wxWindowMSW() // find their parent frame (see above). DestroyChildren(); - if ( m_parent ) - m_parent->RemoveChild(this); - if ( m_hWnd ) { // VZ: test temp removed to understand what really happens here diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 9159d1d295..daea0da4e1 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -362,9 +362,6 @@ wxWindowOS2::~wxWindowOS2() DestroyChildren(); - if (m_parent) - m_parent->RemoveChild(this); - if (m_hWnd) { if(!::WinDestroyWindow(GetHWND())) diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 8f9b0c337f..2cd523c2d4 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -348,9 +348,6 @@ wxWindowX11::~wxWindowX11() m_isBeingDeleted = TRUE; - if (m_parent) - m_parent->RemoveChild( this ); - DestroyChildren(); if (m_clientWindow != m_mainWindow) -- 2.47.2