From 6d870fe011d7c8bb59baa3964b736eff50ff4eea Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 16 Aug 2018 19:48:41 +0200 Subject: [PATCH 1/2] Improve wxPD_APP_MODAL description in the documentation Explain the "application modality" concept. --- interface/wx/progdlg.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/interface/wx/progdlg.h b/interface/wx/progdlg.h index 589976076d..d78b49a6fa 100644 --- a/interface/wx/progdlg.h +++ b/interface/wx/progdlg.h @@ -55,8 +55,9 @@ @beginStyleTable @style{wxPD_APP_MODAL} - Make the progress dialog modal. If this flag is not given, it is - only "locally" modal - that is the input to the parent window is + Make the progress dialog application-modal, i.e. disable all + application windows while it is shown. If this flag is not given, it + is only "locally" modal -- that is the input to the parent window is disabled, but not to the other ones. @style{wxPD_AUTO_HIDE} Causes the progress dialog to disappear from screen as soon as the From 25678f60953ad5998f3650a277d0bf628034e084 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 16 Aug 2018 19:57:18 +0200 Subject: [PATCH 2/2] Don't disable main application window in wxProgressDialog Since 58f90d36a01090bb0cd66ec59a96f73ae13d10a6, the main application window was disabled even if no parent was specified when creating wxProgressDialog, which was a change in behaviour compared to 3.1.0 and earlier versions. Revert this change and don't disable any windows if neither parent nor wxPD_APP_MODAL is given. Closes #18189. --- interface/wx/progdlg.h | 6 +++++- src/generic/progdlgg.cpp | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/interface/wx/progdlg.h b/interface/wx/progdlg.h index d78b49a6fa..28ce778ed6 100644 --- a/interface/wx/progdlg.h +++ b/interface/wx/progdlg.h @@ -105,7 +105,11 @@ public: In the generic implementation the progress bar is constructed only if this value is greater than zero. @param parent - Parent window. + Parent window. It will be disabled while this dialog is shown if + non-null (whether @c wxPD_APP_MODAL is specified or not). Note that + if you specify null parent and don't use @c wxPD_APP_MODAL, you + need to take care to avoid reentrancies, i.e. avoiding showing the + progress dialog again while this one is shown. @param style The dialog style. See wxProgressDialog. */ diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index 03e1e7f933..4c7b1d0ef4 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -134,7 +134,14 @@ wxGenericProgressDialog::wxGenericProgressDialog(const wxString& title, void wxGenericProgressDialog::SetTopParent(wxWindow* parent) { m_parent = parent; - m_parentTop = GetParentForModalDialog(parent, GetWindowStyle()); + + // Notice that we intentionally do not use GetParentForModalDialog() here + // as we don't want to disable the main application window if null parent + // was given (and GetParentForModalDialog() would fall back to it in this + // case). This allows creating modeless progress dialog, which can be + // useful even though it is also dangerous because it can easily result in + // unwanted reentrancies. + m_parentTop = parent; } bool wxGenericProgressDialog::Create( const wxString& title,