X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3aa8e4ea6db0478d3bc862f59f100408bdc8732f..4ca8531f6195e4daae4756a396ba00f23cad2166:/src/univ/dialog.cpp diff --git a/src/univ/dialog.cpp b/src/univ/dialog.cpp index ad510bd277..9adf6a99b8 100644 --- a/src/univ/dialog.cpp +++ b/src/univ/dialog.cpp @@ -41,8 +41,6 @@ BEGIN_EVENT_TABLE(wxDialog,wxDialogBase) EVT_CLOSE (wxDialog::OnCloseWindow) END_EVENT_TABLE() -IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxTopLevelWindow) - void wxDialog::Init() { m_returnCode = 0; @@ -53,6 +51,9 @@ void wxDialog::Init() wxDialog::~wxDialog() { + // if the dialog is modal, this will end its event loop + Show(false); + delete m_eventLoop; } @@ -140,11 +141,7 @@ bool wxDialog::Show(bool show) // if we had disabled other app windows, reenable them back now because // if they stay disabled Windows will activate another window (one // which is enabled, anyhow) and we will lose activation - if ( m_windowDisabler ) - { - delete m_windowDisabler; - m_windowDisabler = NULL; - } + wxDELETE(m_windowDisabler); if ( IsModal() ) EndModal(wxID_CANCEL); @@ -176,20 +173,17 @@ int wxDialog::ShowModal() // use the apps top level window as parent if none given unless explicitly // forbidden - if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) ) + wxWindow * const parent = GetParentForModalDialog(); + if ( parent && parent != this ) { - wxWindow * const parent = GetParentForModalDialog(); - if ( parent && parent != this ) - { - m_parent = parent; - } + m_parent = parent; } Show(true); m_isShowingModal = true; - wxASSERT_MSG( !m_windowDisabler, _T("disabling windows twice?") ); + wxASSERT_MSG( !m_windowDisabler, wxT("disabling windows twice?") ); #if defined(__WXGTK__) || defined(__WXMGL__) wxBusyCursorSuspender suspender; @@ -207,7 +201,7 @@ int wxDialog::ShowModal() void wxDialog::EndModal(int retCode) { - wxASSERT_MSG( m_eventLoop, _T("wxDialog is not modal") ); + wxASSERT_MSG( m_eventLoop, wxT("wxDialog is not modal") ); SetReturnCode(retCode);