From: Vadim Zeitlin Date: Fri, 17 Jul 2009 16:52:43 +0000 (+0000) Subject: No real changes, just refactor wxEventLoop/wxApp::ProcessIdle(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a758f601dd53ef1653a6a137bf3fdb37cc185941 No real changes, just refactor wxEventLoop/wxApp::ProcessIdle(). Old code called wxApp::ProcessIdle() from wxEventLoopManualRun::Run() which called wxEventLoop::ProcessIdle() which called wxApp methods from it. In the new version wxEventLoopManualRun::Run() calls wxEventLoopManualRun::ProcessIdle() which calls wxApp::ProcessIdle() which calls other wxApp methods which seems to make more sense and also allows overriding ProcessIdle() in either wxEventLoopManual or wxApp-derived classes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61441 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/app.h b/include/wx/app.h index f754a7b117..a4478b6977 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -320,6 +320,8 @@ public: // wxEventLoop redirections // ------------------------ + // all these functions are forwarded to the corresponding methods of the + // currently active event loop -- and do nothing if there is none virtual bool Pending(); virtual bool Dispatch(); @@ -329,6 +331,13 @@ public: bool Yield(bool onlyIfNeeded = false); virtual void WakeUpIdle(); + + // this method is called by the active event loop when there are no events + // to process + // + // by default it generates the idle events and if you override it in your + // derived class you should call the base class version to ensure that idle + // events are still sent out virtual bool ProcessIdle(); diff --git a/include/wx/evtloop.h b/include/wx/evtloop.h index 8bea93090a..6b2e7c7c95 100644 --- a/include/wx/evtloop.h +++ b/include/wx/evtloop.h @@ -99,12 +99,13 @@ public: // idle handling // ------------- - // make sure that idle events are sent again + // make sure that idle events are sent again virtual void WakeUpIdle(); // this virtual function is called when the application - // becomes idle and normally just sends wxIdleEvent to all interested - // parties + // becomes idle and by default it forwards to wxApp::ProcessIdle() and + // while it can be overridden in a custom event loop, you must call the + // base class version to ensure that idle events are still generated // // it should return true if more idle events are needed, false if not virtual bool ProcessIdle(); diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 14a4cf64da..936d8d21b5 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -333,9 +333,15 @@ void wxAppConsoleBase::WakeUpIdle() bool wxAppConsoleBase::ProcessIdle() { - wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); + // process pending wx events before sending idle events + ProcessPendingEvents(); + + // synthesize an idle event and check if more of them are needed + wxIdleEvent event; + event.SetEventObject(this); + ProcessEvent(event); - return loop && loop->ProcessIdle(); + return event.MoreRequested(); } // ---------------------------------------------------------------------------- diff --git a/src/common/evtloopcmn.cpp b/src/common/evtloopcmn.cpp index 15813725a8..f4adbbed10 100644 --- a/src/common/evtloopcmn.cpp +++ b/src/common/evtloopcmn.cpp @@ -63,18 +63,7 @@ void wxEventLoopBase::WakeUpIdle() bool wxEventLoopBase::ProcessIdle() { - if (!wxTheApp) - return false; - - // process pending wx events before sending idle events - wxTheApp->ProcessPendingEvents(); - - // synthetize an idle event and send it to wxApp - wxIdleEvent event; - event.SetEventObject(wxTheApp); - wxTheApp->ProcessEvent(event); - - return event.MoreRequested(); + return wxTheApp && wxTheApp->ProcessIdle(); } bool wxEventLoopBase::Yield(bool onlyIfNeeded) @@ -135,7 +124,7 @@ int wxEventLoopManual::Run() // generate and process idle events for as long as we don't // have anything else to do - while ( !Pending() && (wxTheApp && wxTheApp->ProcessIdle()) ) + while ( !Pending() && ProcessIdle() ) ; // if the "should exit" flag is set, the loop should terminate