don't use GetParent() in GetParentForModalDialog() itself as it can be called before m_parent is initialized
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60573 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -90,8 +90,11 @@ public:
|
||||
void SetEscapeId(int escapeId);
|
||||
int GetEscapeId() const { return m_escapeId; }
|
||||
|
||||
// Returns the parent to use for modal dialogs if the user did not specify it
|
||||
// explicitly. If parent argument is NULL, use GetParent() by default.
|
||||
// Find the parent to use for modal dialog: try to use the specified parent
|
||||
// but fall back to the current active window or main application window as
|
||||
// last resort if it is unsuitable.
|
||||
//
|
||||
// This function always returns a valid top level window or NULL.
|
||||
wxWindow *GetParentForModalDialog(wxWindow *parent = NULL) const;
|
||||
|
||||
#if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
|
||||
|
@@ -80,8 +80,10 @@ void wxDialogBase::Init()
|
||||
|
||||
wxWindow *wxDialogBase::CheckIfCanBeUsedAsParent(wxWindow *parent) const
|
||||
{
|
||||
extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete;
|
||||
if ( !parent )
|
||||
return NULL;
|
||||
|
||||
extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete;
|
||||
if ( wxPendingDelete.Member(parent) || parent->IsBeingDeleted() )
|
||||
{
|
||||
// this window is being deleted and we shouldn't create any children
|
||||
@@ -120,17 +122,14 @@ wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const
|
||||
if ( HasFlag(wxDIALOG_NO_PARENT) )
|
||||
return NULL;
|
||||
|
||||
// by default, use the parent specified in the ctor
|
||||
if ( !parent )
|
||||
parent = GetParent();
|
||||
|
||||
// first try the given parent
|
||||
if ( parent )
|
||||
parent = CheckIfCanBeUsedAsParent(wxGetTopLevelParent(parent));
|
||||
|
||||
// then the currently active window
|
||||
if ( !parent )
|
||||
parent = CheckIfCanBeUsedAsParent(wxGetActiveWindow());
|
||||
parent = CheckIfCanBeUsedAsParent(
|
||||
wxGetTopLevelParent(wxGetActiveWindow()));
|
||||
|
||||
// and finally the application main window
|
||||
if ( !parent )
|
||||
|
@@ -111,7 +111,7 @@ int wxDialog::ShowModal()
|
||||
if ( win )
|
||||
win->GTKReleaseMouseAndNotify();
|
||||
|
||||
wxWindow * const parent = GetParentForModalDialog();
|
||||
wxWindow * const parent = GetParentForModalDialog(GetParent());
|
||||
if ( parent )
|
||||
{
|
||||
gtk_window_set_transient_for( GTK_WINDOW(m_widget),
|
||||
|
@@ -375,7 +375,8 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
|
||||
#else // !__WXMICROWIN__
|
||||
// static cast is valid as we're only ever called for dialogs
|
||||
wxWindow * const
|
||||
parent = static_cast<wxDialog *>(this)->GetParentForModalDialog();
|
||||
parent = static_cast<wxDialog *>(this)->
|
||||
GetParentForModalDialog(GetParent());
|
||||
|
||||
m_hWnd = (WXHWND)::CreateDialogIndirect
|
||||
(
|
||||
|
Reference in New Issue
Block a user