From 0e86e26936bb997235a92adc31ccba69b73b5047 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 30 Jun 2000 13:38:08 +0000 Subject: [PATCH] unset the dialog as top level window in Destroy(), not in dtor git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7659 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/dialog.cpp | 22 ++++++++++++++-------- src/gtk1/dialog.cpp | 22 ++++++++++++++-------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 102b7dfe08..9263599ca6 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -316,13 +316,6 @@ wxDialog::~wxDialog() { m_isBeingDeleted = TRUE; - wxTopLevelWindows.DeleteObject( this ); - - if (wxTheApp->GetTopWindow() == this) - { - wxTheApp->SetTopWindow( (wxWindow*) NULL ); - } - if ((wxTopLevelWindows.Number() == 0) && (wxTheApp->GetExitOnFrameDelete())) { @@ -412,7 +405,20 @@ void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) bool wxDialog::Destroy() { - if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); + // schedule the dialog for the deletion + if ( !wxPendingDelete.Member(this) ) + { + wxPendingDelete.Append(this); + } + + // don't leave a dangling pointer as the app top window, we can be deleted + // any moment at all now! + if ( wxTheApp->GetTopWindow() == this ) + { + wxTheApp->SetTopWindow( (wxWindow*) NULL ); + } + + wxTopLevelWindows.DeleteObject( this ); return TRUE; } diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 102b7dfe08..9263599ca6 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -316,13 +316,6 @@ wxDialog::~wxDialog() { m_isBeingDeleted = TRUE; - wxTopLevelWindows.DeleteObject( this ); - - if (wxTheApp->GetTopWindow() == this) - { - wxTheApp->SetTopWindow( (wxWindow*) NULL ); - } - if ((wxTopLevelWindows.Number() == 0) && (wxTheApp->GetExitOnFrameDelete())) { @@ -412,7 +405,20 @@ void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) bool wxDialog::Destroy() { - if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); + // schedule the dialog for the deletion + if ( !wxPendingDelete.Member(this) ) + { + wxPendingDelete.Append(this); + } + + // don't leave a dangling pointer as the app top window, we can be deleted + // any moment at all now! + if ( wxTheApp->GetTopWindow() == this ) + { + wxTheApp->SetTopWindow( (wxWindow*) NULL ); + } + + wxTopLevelWindows.DeleteObject( this ); return TRUE; }