X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9977626de47d133617d2525aebe9049754de5374..4e209a2064a2b6d97b810ccab66859ab30b4bf2a:/src/cocoa/app.mm diff --git a/src/cocoa/app.mm b/src/cocoa/app.mm index 71704b5e28..fc253712db 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" @@ -40,6 +41,7 @@ #import #import #import +#import // ---------------------------------------------------------------------------- // globals @@ -97,21 +99,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 +121,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() @@ -147,6 +134,7 @@ END_EVENT_TABLE() bool wxApp::Initialize(int& argc, wxChar **argv) { wxAutoNSAutoreleasePool pool; + m_cocoaMainThread = [NSThread currentThread]; // Mac OS X passes a process serial number command line argument when // the application is launched from the Finder. This argument must be // removed from the command line arguments before being handled by the @@ -182,7 +170,6 @@ void wxApp::CleanUp() wxApp::wxApp() { m_topWindow = NULL; - wxTheApp = this; m_isIdle = true; #if WXWIN_COMPATIBILITY_2_2 @@ -196,6 +183,12 @@ wxApp::wxApp() void wxApp::CocoaInstallIdleHandler() { + // If we're not the main thread, don't install the idle handler + if(m_cocoaMainThread != [NSThread currentThread]) + { + wxLogDebug("Attempt to install idle handler from secondary thread"); + return; + } // If we're supposed to be stopping, don't add more idle events if(![m_cocoaApp isRunning]) return; @@ -226,7 +219,7 @@ bool wxApp::OnInitGui() bool wxApp::CallOnInit() { - wxAutoNSAutoreleasePool pool; +// wxAutoNSAutoreleasePool pool; return OnInit(); } @@ -278,37 +271,6 @@ void wxApp::Dispatch() { } -void wxApp::OnIdle(wxIdleEvent& event) -{ - wxLogDebug("wxApp::OnIdle"); -#if 0 - static bool s_inOnIdle = FALSE; - - // Avoid recursion (via ProcessEvent default case) - if ( s_inOnIdle ) - return; - s_inOnIdle = TRUE; -#endif - - - DeletePendingObjects(); - - // flush the logged messages if any - wxLog *pLog = wxLog::GetActiveTarget(); - if ( pLog != NULL && pLog->HasPendingMessages() ) - pLog->Flush(); - -#if 0 - // Send OnIdle events to all windows - bool needMore = SendIdleEvents(); - - if (needMore) - event.RequestMore(TRUE); - - s_inOnIdle = FALSE; -#endif -} - // Yield to other processes bool wxApp::Yield(bool onlyIfNeeded)