X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e39af974ef7846e26686ae39d74e4696c1fef0c3..f3e28ade43cf9d6bd1c158280939870249cc9d2a:/src/cocoa/app.mm diff --git a/src/cocoa/app.mm b/src/cocoa/app.mm index 89c16115f3..d5c70c6f32 100644 --- a/src/cocoa/app.mm +++ b/src/cocoa/app.mm @@ -31,6 +31,7 @@ #include "wx/module.h" #include "wx/cocoa/ObjcPose.h" +#include "wx/cocoa/autorelease.h" #if wxUSE_WX_RESOURCES # include "wx/resource.h" @@ -97,21 +98,6 @@ wxPoseAsInitializer *wxPoseAsInitializer::sm_first = NULL; @end // wxPoserNSApplication WX_IMPLEMENT_POSER(wxPoserNSApplication); -class wxAutoNSAutoreleasePool -{ -public: - wxAutoNSAutoreleasePool() - { - m_pool = [[NSAutoreleasePool alloc] init]; - } - ~wxAutoNSAutoreleasePool() - { - [m_pool release]; - } -protected: - NSAutoreleasePool *m_pool; -}; - // ============================================================================ // functions // ============================================================================ @@ -134,7 +120,7 @@ void wxApp::Exit() #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) - EVT_IDLE(wxApp::OnIdle) + EVT_IDLE(wxAppBase::OnIdle) // EVT_END_SESSION(wxApp::OnEndSession) // EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession) END_EVENT_TABLE() @@ -196,6 +182,9 @@ wxApp::wxApp() void wxApp::CocoaInstallIdleHandler() { + // If we're supposed to be stopping, don't add more idle events + if(![m_cocoaApp isRunning]) + return; wxLogDebug("wxApp::CocoaInstallIdleHandler"); m_isIdle = false; // Call doIdle for EVERYTHING dammit @@ -223,7 +212,7 @@ bool wxApp::OnInitGui() bool wxApp::CallOnInit() { - wxAutoNSAutoreleasePool pool; +// wxAutoNSAutoreleasePool pool; return OnInit(); } @@ -261,7 +250,7 @@ void wxApp::ExitMainLoop() if(!m_isIdle) [[ NSRunLoop currentRunLoop ] cancelPerformSelector:@selector(doIdle:) target:m_cocoaApp argument:NULL]; #endif - [m_cocoaApp terminate: m_cocoaApp]; + [m_cocoaApp stop: m_cocoaApp]; } // Is a message/event pending? @@ -275,33 +264,6 @@ void wxApp::Dispatch() { } -void wxApp::OnIdle(wxIdleEvent& event) -{ - wxLogDebug("wxApp::OnIdle"); - static bool s_inOnIdle = FALSE; - - // Avoid recursion (via ProcessEvent default case) - if ( s_inOnIdle ) - return; - s_inOnIdle = TRUE; - - - DeletePendingObjects(); - - // flush the logged messages if any - wxLog *pLog = wxLog::GetActiveTarget(); - if ( pLog != NULL && pLog->HasPendingMessages() ) - pLog->Flush(); - - // Send OnIdle events to all windows - bool needMore = SendIdleEvents(); - - if (needMore) - event.RequestMore(TRUE); - - s_inOnIdle = FALSE; -} - // Yield to other processes bool wxApp::Yield(bool onlyIfNeeded)