void wxAppBase::CleanUp() { // clean up all the pending objects DeletePendingObjects(); // and any remaining TLWs (they remove themselves from wxTopLevelWindows // when destroyed, so iterate until none are left) while ( !wxTopLevelWindows.empty() ) { // do not use Destroy() here as it only puts the TLW in pending list // but we want to delete them now delete wxTopLevelWindows.GetFirst()->GetData(); } // undo everything we did in Initialize() above wxBitmap::CleanUpHandlers(); wxStockGDI::DeleteAll(); wxDeleteStockLists(); wxDELETE(wxTheColourDatabase); wxAppConsole::CleanUp(); }
// Returns true if more time is needed. bool wxAppBase::ProcessIdle() { // call the base class version first, it will process the pending events // (which should be done before the idle events generation) and send the // idle event to wxTheApp itself bool needMore = wxAppConsoleBase::ProcessIdle(); wxIdleEvent event; wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); while (node) { wxWindow* win = node->GetData(); if (SendIdleEvents(win, event)) needMore = true; node = node->GetNext(); } // 'Garbage' collection of windows deleted with Close(). DeletePendingObjects(); #if wxUSE_LOG // flush the logged messages if any wxLog::FlushActive(); #endif wxUpdateUIEvent::ResetUpdateTime(); return needMore; }
void wxApp::MacDoOneEvent() { EventRef theEvent; s_inReceiveEvent = true ; OSStatus status = ReceiveNextEvent(0, NULL,sleepTime,true,&theEvent) ; s_inReceiveEvent = false ; if ( status == eventLoopTimedOutErr ) { if ( wxTheApp->ProcessIdle() ) sleepTime = kEventDurationNoWait ; else sleepTime = kEventDurationSecond; } else if ( status == eventLoopQuitErr ) { // according to QA1061 this may also occur when a WakeUp Process // is executed } else { MacHandleOneEvent( theEvent ) ; ReleaseEvent(theEvent); sleepTime = kEventDurationNoWait ; } // repeaters DeletePendingObjects() ; wxMacProcessNotifierAndPendingEvents() ; }
// Returns true if more time is needed. bool wxAppBase::ProcessIdle() { // process pending wx events before sending idle events ProcessPendingEvents(); wxIdleEvent event; bool needMore = false; wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); while (node) { wxWindow* win = node->GetData(); if (SendIdleEvents(win, event)) needMore = true; node = node->GetNext(); } event.SetEventObject(this); (void) ProcessEvent(event); if (event.MoreRequested()) needMore = true; // 'Garbage' collection of windows deleted with Close(). DeletePendingObjects(); #if wxUSE_LOG // flush the logged messages if any wxLog::FlushActive(); #endif wxUpdateUIEvent::ResetUpdateTime(); return needMore; }
void wxApp::MacDoOneEvent() { wxMacAutoreleasePool autoreleasepool; EventRef theEvent; s_inReceiveEvent = true ; OSStatus status = ReceiveNextEvent(0, NULL, sleepTime, true, &theEvent) ; s_inReceiveEvent = false ; switch (status) { case eventLoopTimedOutErr : if ( wxTheApp->ProcessIdle() ) sleepTime = kEventDurationNoWait ; else sleepTime = kEventDurationSecond; break; case eventLoopQuitErr : // according to QA1061 this may also occur // when a WakeUp Process is executed break; default: MacHandleOneEvent( theEvent ) ; ReleaseEvent( theEvent ); sleepTime = kEventDurationNoWait ; break; } // repeaters DeletePendingObjects() ; wxMacProcessNotifierAndPendingEvents() ; }
void wxAppBase::CleanUp() { // Clean up any still pending objects. Normally there shouldn't any as we // already do this in OnExit(), but this could happen if the user code has // somehow managed to create more of them since then or just forgot to call // the base class OnExit(). DeletePendingObjects(); // and any remaining TLWs (they remove themselves from wxTopLevelWindows // when destroyed, so iterate until none are left) while ( !wxTopLevelWindows.empty() ) { // do not use Destroy() here as it only puts the TLW in pending list // but we want to delete them now delete wxTopLevelWindows.GetFirst()->GetData(); } // undo everything we did in Initialize() above wxBitmap::CleanUpHandlers(); wxStockGDI::DeleteAll(); wxDeleteStockLists(); wxDELETE(wxTheColourDatabase); wxAppConsole::CleanUp(); }
int wxAppConsoleBase::OnExit() { // Delete all pending objects first, they might use wxConfig to save their // state during their destruction. DeletePendingObjects(); #if wxUSE_CONFIG // delete the config object if any (don't use Get() here, but Set() // because Get() could create a new config object) delete wxConfigBase::Set(NULL); #endif // wxUSE_CONFIG return 0; }
bool wxAppConsoleBase::ProcessIdle() { // synthesize an idle event and check if more of them are needed wxIdleEvent event; event.SetEventObject(this); ProcessEvent(event); #if wxUSE_LOG // flush the logged messages if any (do this after processing the events // which could have logged new messages) wxLog::FlushActive(); #endif // Garbage collect all objects previously scheduled for destruction. DeletePendingObjects(); return event.MoreRequested(); }
void wxAppConsoleBase::ProcessPendingEvents() { if ( m_bDoPendingEventProcessing ) { wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); wxCHECK_RET( m_handlersWithPendingDelayedEvents.IsEmpty(), "this helper list should be empty" ); // iterate until the list becomes empty: the handlers remove themselves // from it when they don't have any more pending events while (!m_handlersWithPendingEvents.IsEmpty()) { // In ProcessPendingEvents(), new handlers might be added // and we can safely leave the critical section here. wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); // NOTE: we always call ProcessPendingEvents() on the first event handler // with pending events because handlers auto-remove themselves // from this list (see RemovePendingEventHandler) if they have no // more pending events. m_handlersWithPendingEvents[0]->ProcessPendingEvents(); wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); } // now the wxHandlersWithPendingEvents is surely empty; however some event // handlers may have moved themselves into wxHandlersWithPendingDelayedEvents // because of a selective wxYield call in progress. // Now we need to move them back to wxHandlersWithPendingEvents so the next // call to this function has the chance of processing them: if (!m_handlersWithPendingDelayedEvents.IsEmpty()) { WX_APPEND_ARRAY(m_handlersWithPendingEvents, m_handlersWithPendingDelayedEvents); m_handlersWithPendingDelayedEvents.Clear(); } wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); } // Garbage collect all objects previously scheduled for destruction. DeletePendingObjects(); }
void wxAppBase::OnIdle(wxIdleEvent& WXUNUSED(event)) { // If there are pending events, we must process them: pending events // are either events to the threads other than main or events posted // with wxPostEvent() functions // GRG: I have moved this here so that all pending events are processed // before starting to delete any objects. This behaves better (in // particular, wrt wxPostEvent) and is coherent with wxGTK's current // behaviour. Changed Feb/2000 before 2.1.14 ProcessPendingEvents(); // 'Garbage' collection of windows deleted with Close(). DeletePendingObjects(); #if wxUSE_LOG // flush the logged messages if any wxLog::FlushActive(); #endif // wxUSE_LOG }
void wxAppBase::CleanUp() { // clean up all the pending objects DeletePendingObjects(); // and any remaining TLWs (they remove themselves from wxTopLevelWindows // when destroyed, so iterate until none are left) while ( !wxTopLevelWindows.empty() ) { // do not use Destroy() here as it only puts the TLW in pending list // but we want to delete them now delete wxTopLevelWindows.GetFirst()->GetData(); } // undo everything we did in Initialize() above wxBitmap::CleanUpHandlers(); wxStockGDI::DeleteAll(); wxDeleteStockLists(); delete wxTheColourDatabase; wxTheColourDatabase = NULL; delete wxPendingEvents; wxPendingEvents = NULL; #if wxUSE_THREADS delete wxPendingEventsLocker; wxPendingEventsLocker = NULL; #if wxUSE_VALIDATORS // If we don't do the following, we get an apparent memory leak. ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker(); #endif // wxUSE_VALIDATORS #endif // wxUSE_THREADS }