From: Vadim Zeitlin Date: Mon, 23 Apr 2007 20:07:26 +0000 (+0000) Subject: test that the candidate parent window isn't being deleted (this would result in a... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/893f78406dcd40841cd39294112f6382945a7be8?ds=inline test that the candidate parent window isn't being deleted (this would result in a crash later) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45604 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 7100e0fd7a..8430081563 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -72,6 +72,17 @@ void wxDialogBase::Init() WX_INIT_CONTROL_CONTAINER(); } +// helper of GetParentForModalDialog() +static bool CanBeUsedAsParent(wxWindow *parent) +{ + extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete; + + return !parent->HasExtraStyle(wxWS_EX_TRANSIENT) && + parent->IsShownOnScreen() && + !wxPendingDelete.Member(parent) && + parent->IsBeingDeleted(); +} + wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const { // creating a parent-less modal dialog will result (under e.g. wxGTK2) @@ -79,10 +90,10 @@ wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const if ( parent ) parent = wxGetTopLevelParent(parent); - if ( !parent || parent->HasExtraStyle(wxWS_EX_TRANSIENT) ) + if ( !parent || !CanBeUsedAsParent(parent) ) parent = wxTheApp->GetTopWindow(); - if ( parent && parent->HasExtraStyle(wxWS_EX_TRANSIENT) ) + if ( parent && !CanBeUsedAsParent(parent) ) { // can't use this one, it's going to disappear parent = NULL;