diff --git a/src/dfb/toplevel.cpp b/src/dfb/toplevel.cpp index 5c042f3358..b5dcc161da 100644 --- a/src/dfb/toplevel.cpp +++ b/src/dfb/toplevel.cpp @@ -176,16 +176,11 @@ wxTopLevelWindowDFB::~wxTopLevelWindowDFB() { m_isBeingDeleted = true; - wxTopLevelWindows.DeleteObject(this); - - if ( wxTheApp->GetTopWindow() == this ) - wxTheApp->SetTopWindow(NULL); - - if ( wxTopLevelWindows.empty() && wxTheApp->GetExitOnFrameDelete() ) - { - wxTheApp->ExitMainLoop(); - } + // destroy all children before we destroy the underlying DirectFB window, + // so that if any of them does something with the TLW, it will still work: + DestroyChildren(); + // it's safe to delete the underlying DirectFB window now: wxDELETE(m_toPaint); if ( !m_dfbwin )