]> git.saurik.com Git - wxWidgets.git/commitdiff
delete children in ~wxWindow dtor and not in the base class ~wxWindowNative as it...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 12 Dec 2004 17:47:06 +0000 (17:47 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 12 Dec 2004 17:47:06 +0000 (17:47 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30959 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/univ/window.h
src/univ/winuniv.cpp

index 3761d2e79d3b51e98477636637223a07736b9cf2..c39940a21a19cf666848f8724b0807c1a98d4fcb 100644 (file)
@@ -73,6 +73,8 @@ public:
                 long style = 0,
                 const wxString& name = wxPanelNameStr);
 
+    virtual ~wxWindow();
+
     // background pixmap support
     // -------------------------
 
index 21deb2f067bb454b3a4ccb647df41d6cdff763c7..6d57da70e001562d0e55820dcea6294d8c35ac07 100644 (file)
@@ -122,13 +122,13 @@ bool wxWindow::Create(wxWindow *parent,
                       const wxString& name)
 {
     long actualStyle = style;
-    
+
     // FIXME: may need this on other platforms
 #ifdef __WXMSW__
     actualStyle &= ~wxVSCROLL;
     actualStyle &= ~wxHSCROLL;
-#endif    
-    
+#endif
+
     // we add wxCLIP_CHILDREN to get the same ("natural") behaviour under MSW
     // as under the other platforms
     if ( !wxWindowNative::Create(parent, id, pos, size,
@@ -169,7 +169,7 @@ bool wxWindow::Create(wxWindow *parent,
         SetInsertIntoMain( false );
 #endif
     }
-    
+
     if (m_scrollbarHorz || m_scrollbarVert)
     {
         // position it/them
@@ -179,6 +179,18 @@ bool wxWindow::Create(wxWindow *parent,
     return true;
 }
 
+wxWindow::~wxWindow()
+{
+    m_isBeingDeleted = true;
+
+    // we have to destroy our children before we're destroyed because our
+    // children suppose that we're of type wxWindow, not just wxWindowNative,
+    // and so bad things may happen if they're deleted from the base class dtor
+    // as by then we're not a wxWindow any longer and wxUniv-specific virtual
+    // functions can't be called
+    DestroyChildren();
+}
+
 // ----------------------------------------------------------------------------
 // background pixmap
 // ----------------------------------------------------------------------------
@@ -426,11 +438,11 @@ void wxWindow::Refresh(bool eraseBackground, const wxRect *rectClient)
     while ( node )
     {
         wxWindow *win = node->GetData();
-        // Only refresh sub controls when it is visible 
+        // Only refresh sub controls when it is visible
         // and when it is in the update region.
         if(!win->IsKindOf(CLASSINFO(wxTopLevelWindow)) && win->IsShown() && wxRegion(rectWin).Contains(win->GetRect()) != wxOutRegion)
             win->Refresh(eraseBackground, &rectWin);
-            
+
         node = node->GetNext();
     }
 }