X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/df57f6bea383ec80dc2aefbdbe631cc79b68fcfa..c7074d44198d548dd19e7906b697d019b3c01770:/src/common/dlgcmn.cpp diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 7100e0fd7a..92417acc0e 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -52,12 +52,8 @@ BEGIN_EVENT_TABLE(wxDialogBase, wxTopLevelWindow) EVT_CLOSE(wxDialogBase::OnCloseWindow) EVT_CHAR_HOOK(wxDialogBase::OnCharHook) - - WX_EVENT_TABLE_CONTROL_CONTAINER(wxDialogBase) END_EVENT_TABLE() -WX_DELEGATE_TO_CONTROL_CONTAINER(wxDialogBase, wxTopLevelWindow) - void wxDialogBase::Init() { m_returnCode = 0; @@ -68,8 +64,17 @@ void wxDialogBase::Init() // dialog controls from reaching the parent frame which is usually // undesirable and can lead to unexpected and hard to find bugs SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS); +} + +// helper of GetParentForModalDialog() +static bool CanBeUsedAsParent(wxWindow *parent) +{ + extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete; - WX_INIT_CONTROL_CONTAINER(); + return !parent->HasExtraStyle(wxWS_EX_TRANSIENT) && + parent->IsShownOnScreen() && + !wxPendingDelete.Member(parent) && + !parent->IsBeingDeleted(); } wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const @@ -79,10 +84,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;