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
// 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();
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();
// 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();
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();
}
// ----------------------------------------------------------------------------
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)
// 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