X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/50ef256ed3e52defe91655da5e3f6a9e913c9e2a..9869734d0431a29732006119f2d4ed35af70ca9b:/src/msw/app.cpp diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 516e779441..be78f82319 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -92,6 +92,10 @@ extern char *wxBuffer; extern char *wxOsVersion; extern wxList *wxWinHandleList; extern wxList WXDLLEXPORT wxPendingDelete; +#if wxUSE_THREADS +extern wxList *wxPendingEvents; +extern wxCriticalSection *wxPendingEventsLocker; +#endif extern void wxSetKeyboardHook(bool doIt); extern wxCursor *g_globalCursor; @@ -165,6 +169,12 @@ bool wxApp::Initialize() wxGetResource("wxWindows", "OsVersion", &wxOsVersion); #endif + // I'm annoyed ... I don't know where to put this and I don't want to create // a module for that as it's part of the core. +#if wxUSE_THREADS + wxPendingEvents = new wxList(); + wxPendingEventsLocker = new wxCriticalSection(); +#endif + wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase->Initialize(); @@ -547,6 +557,13 @@ void wxApp::CleanUp() if (wxWinHandleList) delete wxWinHandleList ; + // GL: I'm annoyed ... I don't know where to put this and I don't want to + // create a module for that as it's part of the core. +#if wxUSE_THREADS + delete wxPendingEvents; + delete wxPendingEventsLocker; +#endif + wxClassInfo::CleanUpClasses(); delete wxTheApp; @@ -557,7 +574,7 @@ void wxApp::CleanUp() // blocks that aren't part of the wxDebugContext itself, // as a special case. Then when dumping we need to ignore // wxDebugContext, too. - if (wxDebugContext::CountObjectsLeft() > 0) + if (wxDebugContext::CountObjectsLeft(TRUE) > 0) { wxLogDebug("There were memory leaks."); wxDebugContext::Dump(); @@ -893,7 +910,13 @@ int wxApp::MainLoop() { } + DoMessage(); + + // If they are pending events, we must process them. +#if wxUSE_THREADS + ProcessPendingEvents(); +#endif } return s_currentMsg.wParam; @@ -909,6 +932,25 @@ bool wxApp::ProcessIdle() return event.MoreRequested(); } +#if wxUSE_THREADS +void wxApp::ProcessPendingEvents() +{ + wxNode *node = wxPendingEvents->First(); + wxCriticalSectionLocker locker(*wxPendingEventsLocker); + + while (node) + { + wxEvtHandler *handler = (wxEvtHandler *)node->Data(); + + handler->ProcessPendingEvents(); + + delete node; + node = wxPendingEvents->First(); + } +} +#endif + + void wxApp::ExitMainLoop() { m_keepGoing = FALSE; @@ -987,14 +1029,14 @@ void wxApp::OnIdle(wxIdleEvent& event) bool wxApp::SendIdleEvents() { bool needMore = FALSE; - wxNode* node = wxTopLevelWindows.First(); + + wxWindowList::Node* node = wxTopLevelWindows.GetFirst(); while (node) { - wxWindow* win = (wxWindow*) node->Data(); + wxWindow* win = node->GetData(); if (SendIdleEvents(win)) needMore = TRUE; - - node = node->Next(); + node = node->GetNext(); } return needMore; @@ -1068,8 +1110,8 @@ wxWindow* wxApp::GetTopWindow() const { if (m_topWindow) return m_topWindow; - else if (wxTopLevelWindows.Number() > 0) - return (wxWindow*) wxTopLevelWindows.First()->Data(); + else if (wxTopLevelWindows.GetCount() > 0) + return wxTopLevelWindows.GetFirst()->GetData(); else return NULL; }