X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d48b06bd9039597545de9a862501d57c5f9ec1ea..a9a2485d6464928fcf1012e573f4b3b734238300:/src/generic/progdlgg.cpp diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index 114f32071c..68b58cada4 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -38,9 +38,11 @@ #include "wx/dcclient.h" #include "wx/timer.h" #include "wx/settings.h" + #include "wx/app.h" #endif #include "wx/progdlg.h" +#include "wx/evtloop.h" // --------------------------------------------------------------------------- // macros @@ -401,8 +403,17 @@ wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip) m_msg->SetLabel(_("Done.")); } - wxTheApp->YieldFor(wxEVT_CATEGORY_UI); + wxCHECK_MSG(wxEventLoopBase::GetActive(), false, + "wxProgressDialog::Update needs a running event loop"); + // allow the window to repaint: + // NOTE: since we yield only for UI events with this call, there + // should be no side-effects + wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); + + // NOTE: this call results in a new event loop being created + // and to a call to ProcessPendingEvents() (which may generate + // unwanted re-entrancies). (void)ShowModal(); } else // auto hide @@ -449,9 +460,14 @@ bool wxProgressDialog::Pulse(const wxString& newmsg, bool *skip) bool wxProgressDialog::DoAfterUpdate(bool *skip) { + wxCHECK_MSG(wxEventLoopBase::GetActive(), false, + "wxProgressDialog::DoAfterUpdate needs a running event loop"); + // we have to yield because not only we want to update the display but // also to process the clicks on the cancel and skip buttons - wxTheApp->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT); + // NOTE: using YieldFor() this call shouldn't give re-entrancy problems + // for event handlers not interested to UI/user-input events. + wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT); Update(); @@ -664,13 +680,17 @@ void wxProgressDialog::EnableClose() void wxProgressDialog::UpdateMessage(const wxString &newmsg) { + wxCHECK_RET(wxEventLoopBase::GetActive(), + "wxProgressDialog::UpdateMessage needs a running event loop"); + if ( !newmsg.empty() && newmsg != m_msg->GetLabel() ) { m_msg->SetLabel(newmsg); - Fit(); // adapt to the new label size - - wxTheApp->YieldFor(wxEVT_CATEGORY_UI); + // allow the window to repaint: + // NOTE: since we yield only for UI events with this call, there + // should be no side-effects + wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); } }