diff --git a/src/msw/window.cpp b/src/msw/window.cpp index fb7bb67368..7b171f9f7c 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -297,15 +297,18 @@ wxWindow::~wxWindow() { if ( frame->GetLastFocus() == this ) frame->SetLastFocus((wxWindow*)NULL); - //break; + break; } } + // 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