X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c33522fca7cddc441a316f5b9fb50d7685435ba..b81e45065986abc34676fecc31515efeb3f3a8d4:/src/common/appbase.cpp diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 7b2636e47c..a358cf0dde 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -111,6 +111,8 @@ wxAppConsole *wxAppConsoleBase::ms_appInstance = NULL; wxAppInitializerFunction wxAppConsoleBase::ms_appInitFn = NULL; +wxSocketManager *wxAppTraitsBase::ms_manager = NULL; + // ---------------------------------------------------------------------------- // wxEventLoopPtr // ---------------------------------------------------------------------------- @@ -161,7 +163,7 @@ bool wxAppConsoleBase::Initialize(int& WXUNUSED(argc), wxChar **argv) #endif // wxUSE_INTL #if wxUSE_THREADS - wxPendingEventsLocker = new wxCriticalSection; + wxHandlersWithPendingEventsLocker = new wxCriticalSection; #endif #ifndef __WXPALMOS__ @@ -188,12 +190,12 @@ void wxAppConsoleBase::CleanUp() m_mainLoop = NULL; } - delete wxPendingEvents; - wxPendingEvents = NULL; + delete wxHandlersWithPendingEvents; + wxHandlersWithPendingEvents = NULL; #if wxUSE_THREADS - delete wxPendingEventsLocker; - wxPendingEventsLocker = NULL; + delete wxHandlersWithPendingEventsLocker; + wxHandlersWithPendingEventsLocker = NULL; #endif // wxUSE_THREADS } @@ -325,11 +327,11 @@ bool wxAppConsoleBase::Dispatch() bool wxAppConsoleBase::HasPendingEvents() const { - wxENTER_CRIT_SECT( *wxPendingEventsLocker ); + wxENTER_CRIT_SECT( *wxHandlersWithPendingEventsLocker ); - bool has = wxPendingEvents && !wxPendingEvents->IsEmpty(); + bool has = wxHandlersWithPendingEvents && !wxHandlersWithPendingEvents->IsEmpty(); - wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); + wxLEAVE_CRIT_SECT( *wxHandlersWithPendingEventsLocker ); return has; } @@ -345,34 +347,34 @@ bool wxAppConsoleBase::IsMainLoopRunning() void wxAppConsoleBase::ProcessPendingEvents() { #if wxUSE_THREADS - if ( !wxPendingEventsLocker ) + if ( !wxHandlersWithPendingEventsLocker ) return; #endif - wxENTER_CRIT_SECT( *wxPendingEventsLocker ); + wxENTER_CRIT_SECT( *wxHandlersWithPendingEventsLocker ); - if (wxPendingEvents) + if (wxHandlersWithPendingEvents) { // iterate until the list becomes empty: the handlers remove themselves // from it when they don't have any more pending events - wxList::compatibility_iterator node = wxPendingEvents->GetFirst(); + wxList::compatibility_iterator node = wxHandlersWithPendingEvents->GetFirst(); while (node) { // In ProcessPendingEvents(), new handlers might be add // and we can safely leave the critical section here. - wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); + wxLEAVE_CRIT_SECT( *wxHandlersWithPendingEventsLocker ); wxEvtHandler *handler = (wxEvtHandler *)node->GetData(); handler->ProcessPendingEvents(); - wxENTER_CRIT_SECT( *wxPendingEventsLocker ); + wxENTER_CRIT_SECT( *wxHandlersWithPendingEventsLocker ); // restart as the iterators could have been invalidated - node = wxPendingEvents->GetFirst(); + node = wxHandlersWithPendingEvents->GetFirst(); } } - wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); + wxLEAVE_CRIT_SECT( *wxHandlersWithPendingEventsLocker ); } void wxAppConsoleBase::WakeUpIdle() @@ -383,6 +385,9 @@ void wxAppConsoleBase::WakeUpIdle() bool wxAppConsoleBase::ProcessIdle() { + // process pending wx events before sending idle events + ProcessPendingEvents(); + wxIdleEvent event; event.SetEventObject(this); @@ -411,6 +416,20 @@ wxAppConsoleBase::HandleEvent(wxEvtHandler *handler, (handler->*func)(event); } +void wxAppConsoleBase::CallEventHandler(wxEvtHandler *handler, + wxEventFunctor& functor, + wxEvent& event) const +{ + // If the functor holds a method then, for backward compatibility, call + // HandleEvent(): + wxEventFunction eventFunction = functor.GetMethod(); + + if ( eventFunction ) + HandleEvent(handler, eventFunction, event); + else + functor(handler, event); +} + void wxAppConsoleBase::OnUnhandledException() { #ifdef __WXDEBUG__