From a9efc294a979fb4ae801f7dc37af35677301212d Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 5 Feb 2008 19:13:26 +0000 Subject: [PATCH] call Show(false) from ~wxDialog to call EndModal if the dialog is still modal consistently in all ports git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51562 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/dialog.h | 2 +- src/gtk/dialog.cpp | 11 ++++++++++- src/mac/carbon/dialog.cpp | 2 ++ src/motif/dialog.cpp | 6 ++++++ src/univ/dialog.cpp | 5 +++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/wx/gtk/dialog.h b/include/wx/gtk/dialog.h index 7b73b3b52d..b14cd11007 100644 --- a/include/wx/gtk/dialog.h +++ b/include/wx/gtk/dialog.h @@ -31,7 +31,7 @@ public: const wxSize &size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, const wxString &name = wxDialogNameStr ); - virtual ~wxDialog() {} + virtual ~wxDialog(); virtual bool Show( bool show = TRUE ); virtual int ShowModal(); diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index bb0f74e2ef..8a087ecae6 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -71,11 +71,20 @@ bool wxDialog::Show( bool show ) bool ret = wxWindow::Show( show ); - if (show) InitDialog(); + if (show) + InitDialog(); return ret; } +wxDialog::~wxDialog() +{ + m_isBeingDeleted = true; + + // if the dialog is modal, this will end its event loop + Show(false); +} + bool wxDialog::IsModal() const { return m_modalShowing; diff --git a/src/mac/carbon/dialog.cpp b/src/mac/carbon/dialog.cpp index 858736fd33..bb90e3812b 100644 --- a/src/mac/carbon/dialog.cpp +++ b/src/mac/carbon/dialog.cpp @@ -77,6 +77,8 @@ void wxDialog::SetModal( bool flag ) wxDialog::~wxDialog() { m_isBeingDeleted = true; + + // if the dialog is modal, this will end its event loop Show(false); } diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index ceb4ca922e..3955a68d45 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -183,6 +183,9 @@ wxDialog::~wxDialog() { m_isBeingDeleted = true; + // if the dialog is modal, this will end its event loop + Show(false); + delete m_eventLoop; if (m_mainWidget) @@ -241,6 +244,9 @@ bool wxDialog::Show( bool show ) if( !wxWindowBase::Show( show ) ) return false; + if ( !show && IsModal() ) + EndModal(wxID_CANCEL); + m_isShown = show; if (show) diff --git a/src/univ/dialog.cpp b/src/univ/dialog.cpp index ad510bd277..c98a5e91ac 100644 --- a/src/univ/dialog.cpp +++ b/src/univ/dialog.cpp @@ -53,6 +53,11 @@ void wxDialog::Init() wxDialog::~wxDialog() { + m_isBeingDeleted = true; + + // if the dialog is modal, this will end its event loop + Show(false); + delete m_eventLoop; } -- 2.49.0