From: David Elliott Date: Thu, 3 Jul 2003 15:36:09 +0000 (+0000) Subject: Provide NSAutoreleasePool instances during initialization X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/47f1ad6a7120c2eeba788b5e1300e837ae2e7e58?hp=7fbc89bb02d09a525e8ae537b44c6e1e1d7cb41d Provide NSAutoreleasePool instances during initialization git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21608 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/cocoa/app.h b/include/wx/cocoa/app.h index 7e1a3d832d..ea155949a9 100644 --- a/include/wx/cocoa/app.h +++ b/include/wx/cocoa/app.h @@ -65,6 +65,8 @@ public: virtual bool Initialize(int& argc, wxChar **argv); virtual void CleanUp(); + virtual bool CallOnInit(); + virtual bool OnInit(); virtual bool OnInitGui(); diff --git a/src/cocoa/app.mm b/src/cocoa/app.mm index 62574e7a0e..8f514adc44 100644 --- a/src/cocoa/app.mm +++ b/src/cocoa/app.mm @@ -39,6 +39,7 @@ #import #import #import +#import // ---------------------------------------------------------------------------- // globals @@ -107,6 +108,21 @@ 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 // ============================================================================ @@ -141,6 +157,7 @@ END_EVENT_TABLE() bool wxApp::Initialize(int& argc, wxChar **argv) { + wxAutoNSAutoreleasePool pool; // 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 @@ -199,6 +216,7 @@ void wxApp::CocoaInstallIdleHandler() bool wxApp::OnInitGui() { + wxAutoNSAutoreleasePool pool; if(!wxAppBase::OnInitGui()) return FALSE; @@ -214,6 +232,12 @@ bool wxApp::OnInitGui() return TRUE; } +bool wxApp::CallOnInit() +{ + wxAutoNSAutoreleasePool pool; + return OnInit(); +} + bool wxApp::OnInit() { if(!wxAppBase::OnInit())