X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ec38d07d0343b3fc5af03becd17ce798b96e05db..5a0a15cf56c4bfde818e9d575fb662612e156c2f:/include/wx/app.h diff --git a/include/wx/app.h b/include/wx/app.h index 10a99bf981..5e0e97060e 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -277,14 +277,49 @@ public: #endif // wxUSE_EXCEPTIONS - // wxEventLoop redirections - // ------------------------ - - virtual void SuspendProcessingOfPendingEvents(); - virtual void ResumeProcessingOfPendingEvents(); + // pending events + // -------------- + + // IMPORTANT: all these methods conceptually belong to wxEventLoopBase + // but for many reasons we need to allow queuing of events + // even when there's no event loop (e.g. in wxApp::OnInit); + // this feature is used e.g. to queue events on secondary threads + // or in wxPython to use wx.CallAfter before the GUI is initialized + + // process all events in the m_handlersWithPendingEvents list -- it is necessary + // to call this function to process posted events. This happens during each + // event loop iteration in GUI mode but if there is no main loop, it may be + // also called directly. virtual void ProcessPendingEvents(); + + // check if there are pending events on global pending event list bool HasPendingEvents() const; + // temporary suspends processing of the pending events + void SuspendProcessingOfPendingEvents(); + + // resume processing of the pending events previously stopped because of a + // call to SuspendProcessingOfPendingEvents() + void ResumeProcessingOfPendingEvents(); + + // called by ~wxEvtHandler to (eventually) remove the handler from the list of + // the handlers with pending events + void RemovePendingEventHandler(wxEvtHandler* toRemove); + + // adds an event handler to the list of the handlers with pending events + void AppendPendingEventHandler(wxEvtHandler* toAppend); + + // moves the event handler from the list of the handlers with pending events + //to the list of the handlers with _delayed_ pending events + void DelayPendingEventHandler(wxEvtHandler* toDelay); + + // deletes the current pending events + void DeletePendingEvents(); + + + // wxEventLoop redirections + // ------------------------ + virtual bool Pending(); virtual bool Dispatch(); @@ -388,6 +423,27 @@ protected: // been started yet or has already terminated) wxEventLoopBase *m_mainLoop; + + // pending events management vars: + + // the array of the handlers with pending events which needs to be processed + // inside ProcessPendingEvents() + wxEvtHandlerArray m_handlersWithPendingEvents; + + // helper array used by ProcessPendingEvents() to store the event handlers + // which have pending events but of these events none can be processed right now + // (because of a call to wxEventLoop::YieldFor() which asked to selectively process + // pending events) + wxEvtHandlerArray m_handlersWithPendingDelayedEvents; + +#if wxUSE_THREADS + // this critical section protects both the lists above + wxCriticalSection m_handlersWithPendingEventsLocker; +#endif + + // flag modified by Suspend/ResumeProcessingOfPendingEvents() + bool m_bDoPendingEventProcessing; + friend class WXDLLIMPEXP_FWD_BASE wxEvtHandler; // the application object is a singleton anyhow, there is no sense in