From dc28b8564eedde54359ac0bcb748335fa13cc7e0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 22 Jun 2008 14:40:25 +0000 Subject: [PATCH] allow wxDialog::ShowModal() after Show() (see #1416, #4658, #4664) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54328 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/dialog.h | 11 +++++++++-- src/gtk/dialog.cpp | 1 - src/msw/dialog.cpp | 3 +-- src/osx/carbon/dialog.cpp | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/interface/dialog.h b/interface/dialog.h index 431edf62b7..3052b2e0e5 100644 --- a/interface/dialog.h +++ b/interface/dialog.h @@ -553,8 +553,15 @@ public: bool Show(bool show); /** - Shows a modal dialog. Program flow does not return until the dialog has - been dismissed with EndModal(). + Shows a modal dialog. + + Program flow does not return until the dialog has been dismissed with + EndModal(). + + Notice that it is possible to call ShowModal() for a dialog which had + been previously shown with Show(), this allows to make an existing + modeless dialog modal. However ShowModal() can't be called twice + without intervening EndModal() calls. @return The value set with SetReturnCode(). diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index c61fbca515..dcdaec3cbe 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -99,7 +99,6 @@ void wxDialog::SetModal( bool WXUNUSED(flag) ) int wxDialog::ShowModal() { wxASSERT_MSG( !IsModal(), "ShowModal() can't be called twice" ); - wxASSERT_MSG( !IsShown(), "ShowModal() can't be called after Show()" ); // release the mouse if it's currently captured as the window having it // will be disabled when this dialog is shown -- but will still keep the diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index b0703f2291..1b66274cc1 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -283,8 +283,7 @@ void wxDialog::Raise() // show dialog modally int wxDialog::ShowModal() { - wxASSERT_MSG(!IsShown(), - _T("ShowModal() can't be called for an already shown dialog")); + wxASSERT_MSG( !IsModal(), _T("ShowModal() can't be called twice") ); m_endModalCalled = false; diff --git a/src/osx/carbon/dialog.cpp b/src/osx/carbon/dialog.cpp index 19dbf02e88..7dffcc6db8 100644 --- a/src/osx/carbon/dialog.cpp +++ b/src/osx/carbon/dialog.cpp @@ -169,7 +169,10 @@ int wxDialog::ShowModal() if ( !m_isModalStyle ) SetModal(true); - Show(true); + if ( IsShown() ) + DoShowModal(); + else + Show(true); return GetReturnCode(); } -- 2.45.2