]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
fixed stupid memory leak
[wxWidgets.git] / src / msw / window.cpp
index ae5cf582a6161e70a3247975125ffbcbe5f8068e..7b171f9f7cc9c4d11ec8c01ef07129881ab0c8e4 100644 (file)
@@ -301,11 +301,14 @@ wxWindow::~wxWindow()
         }
     }
 
+    // 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);
 
-    DestroyChildren();
-
     if ( m_hWnd )
     {
         // VZ: test temp removed to understand what really happens here