diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index d1d13da9b3..e948cddd10 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -198,7 +198,7 @@ int wxDialog::ShowModal() if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) ) { wxWindow *parent = wxTheApp->GetTopWindow(); - if ( parent && parent != this ) + if ( parent && parent != this && parent->IsBeingDeleted() ) { m_parent = parent; gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(parent->m_widget) ); diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index d1d13da9b3..e948cddd10 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -198,7 +198,7 @@ int wxDialog::ShowModal() if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) ) { wxWindow *parent = wxTheApp->GetTopWindow(); - if ( parent && parent != this ) + if ( parent && parent != this && parent->IsBeingDeleted() ) { m_parent = parent; gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(parent->m_widget) ); diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 0720766612..8874a8d156 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -192,6 +192,12 @@ bool wxTopLevelWindowMSW::CreateDialog(const wxChar *dlgTemplate, if ( !parent && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) ) { parent = wxTheApp->GetTopWindow(); + + // but don't use the window which is about to be destroyed as parent + if ( parent->IsBeingDeleted() ) + { + parent = NULL; + } } m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(),