From 6818d0909e3a148d00d7c96ba030dd22b8b44c2b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 28 Oct 2017 22:44:22 +0200 Subject: [PATCH] Factor out wxGenericProgressDialog::EnsureActiveEventLoopExists() Make this function reusable in order to allow it to be called from the native MSW wxProgressDialog implementation in the upcoming commit. --- include/wx/generic/progdlgg.h | 3 +++ src/generic/progdlgg.cpp | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/wx/generic/progdlgg.h b/include/wx/generic/progdlgg.h index ae74bd122d..8ff7e97aa5 100644 --- a/include/wx/generic/progdlgg.h +++ b/include/wx/generic/progdlgg.h @@ -105,6 +105,9 @@ protected: // Converts seconds to HH:mm:ss format. static wxString GetFormattedTime(unsigned long timeInSec); + // Create a new event loop if there is no currently running one. + void EnsureActiveEventLoopExists(); + // callback for optional abort button void OnCancel(wxCommandEvent&); diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index f1a6fcc365..b6ec082df9 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -160,11 +160,7 @@ bool wxGenericProgressDialog::Create( const wxString& title, // even if this means we have to start it ourselves (this happens most // commonly during the program initialization, e.g. for the progress // dialogs shown from overridden wxApp::OnInit()). - if ( !wxEventLoopBase::GetActive() ) - { - m_tempEventLoop = new wxEventLoop; - wxEventLoop::SetActive(m_tempEventLoop); - } + EnsureActiveEventLoopExists(); #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // we have to remove the "Close" button from the title bar then as it is @@ -363,6 +359,15 @@ wxString wxGenericProgressDialog::GetFormattedTime(unsigned long timeInSec) return timeAsHMS; } +void wxGenericProgressDialog::EnsureActiveEventLoopExists() +{ + if ( !wxEventLoopBase::GetActive() ) + { + m_tempEventLoop = new wxEventLoop; + wxEventLoop::SetActive(m_tempEventLoop); + } +} + wxStaticText * wxGenericProgressDialog::CreateLabel(const wxString& text, wxSizer *sizer) {