X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4d1ea475c8566b21777045285c5f1cfa2cc7b7cf..08670ea85abf4b4946a9ce64971b591d7b1ee30b:/src/common/appbase.cpp diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 36a65ef6e9..9ac78f57f6 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -6,7 +6,7 @@ // Created: 19.06.2003 (extracted from common/appcmn.cpp) // RCS-ID: $Id$ // Copyright: (c) 2003 Vadim Zeitlin -// License: wxWindows license +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -147,14 +147,17 @@ wxAppConsoleBase::wxAppConsoleBase() // In unicode mode the SetTraceMasks call can cause an apptraits to be // created, but since we are still in the constructor the wrong kind will // be created for GUI apps. Destroy it so it can be created again later. - delete m_traits; - m_traits = NULL; + wxDELETE(m_traits); #endif #endif + + wxEvtHandler::AddFilter(this); } wxAppConsoleBase::~wxAppConsoleBase() { + wxEvtHandler::RemoveFilter(this); + // we're being destroyed and using this object from now on may not work or // even crash so don't leave dangling pointers to it ms_appInstance = NULL; @@ -214,11 +217,7 @@ wxEventLoopBase *wxAppConsoleBase::CreateMainLoop() void wxAppConsoleBase::CleanUp() { - if ( m_mainLoop ) - { - delete m_mainLoop; - m_mainLoop = NULL; - } + wxDELETE(m_mainLoop); } // ---------------------------------------------------------------------------- @@ -350,8 +349,11 @@ bool wxAppConsoleBase::Dispatch() bool wxAppConsoleBase::Yield(bool onlyIfNeeded) { wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); + if ( loop ) + return loop->Yield(onlyIfNeeded); - return loop && loop->Yield(onlyIfNeeded); + wxScopedPtr tmpLoop(CreateMainLoop()); + return tmpLoop->Yield(onlyIfNeeded); } void wxAppConsoleBase::WakeUpIdle() @@ -375,6 +377,9 @@ bool wxAppConsoleBase::ProcessIdle() wxLog::FlushActive(); #endif + // Garbage collect all objects previously scheduled for destruction. + DeletePendingObjects(); + return event.MoreRequested(); } @@ -400,7 +405,7 @@ bool wxAppConsoleBase::IsMainLoopRunning() int wxAppConsoleBase::FilterEvent(wxEvent& WXUNUSED(event)) { // process the events normally by default - return -1; + return Event_Skip; } void wxAppConsoleBase::DelayPendingEventHandler(wxEvtHandler* toDelay) @@ -514,9 +519,6 @@ void wxAppConsoleBase::ProcessPendingEvents() wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); } - - // Garbage collect all objects previously scheduled for destruction. - DeletePendingObjects(); } void wxAppConsoleBase::DeletePendingEvents()