From 0b96d3b905eeee72c3fc24ff81f366fce1a300f2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 28 Oct 2017 19:46:36 +0200 Subject: [PATCH] Dispatch events from the native MSW wxProgressDialog too Do this for compatibility with wxGenericProgressDialog, which always did this and can't really do otherwise as it needs to react to the clicks on its buttons, and also because not doing it results in the other application windows being marked as "not responding" by MSW, which looks bad. Closes #17768. --- include/wx/msw/progdlg.h | 4 ++++ src/msw/progdlg.cpp | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/wx/msw/progdlg.h b/include/wx/msw/progdlg.h index 46650bd9c3..c54d96c689 100644 --- a/include/wx/msw/progdlg.h +++ b/include/wx/msw/progdlg.h @@ -59,6 +59,10 @@ private: // Returns false if the user requested cancelling the dialog. bool DoNativeBeforeUpdate(bool *skip); + // Dispatch the pending events to let the windows to update, just as the + // generic version does. This is done as part of DoNativeBeforeUpdate(). + void DispatchEvents(); + // Updates the various timing informations for both determinate // and indeterminate modes. Requires the shared object to have // been entered. diff --git a/src/msw/progdlg.cpp b/src/msw/progdlg.cpp index bae1c0c723..f3e812ca82 100644 --- a/src/msw/progdlg.cpp +++ b/src/msw/progdlg.cpp @@ -508,9 +508,29 @@ bool wxProgressDialog::Pulse(const wxString& newmsg, bool *skip) return wxGenericProgressDialog::Pulse( newmsg, skip ); } +void wxProgressDialog::DispatchEvents() +{ +#ifdef wxHAS_MSW_TASKDIALOG + // No need for HasNativeTaskDialog() check, we're only called when this is + // the case. + wxEventLoopBase* const loop = wxEventLoop::GetActive(); + if ( loop ) + { + // We don't need to dispatch the user input events as the task dialog + // handles its own ones in its thread and we shouldn't react to any + // other user actions while the dialog is shown. + loop->YieldFor(wxEVT_CATEGORY_ALL & ~wxEVT_CATEGORY_USER_INPUT); + } +#else // !wxHAS_MSW_TASKDIALOG + wxFAIL_MSG( "unreachable" ); +#endif // wxHAS_MSW_TASKDIALOG/!wxHAS_MSW_TASKDIALOG +} + bool wxProgressDialog::DoNativeBeforeUpdate(bool *skip) { #ifdef wxHAS_MSW_TASKDIALOG + DispatchEvents(); + wxCriticalSectionLocker locker(m_sharedData->m_cs); if ( m_sharedData->m_skipped )