Provide NSAutoreleasePool instances during initialization

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21608 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2003-07-03 15:36:09 +00:00
parent 7fbc89bb02
commit 47f1ad6a71
2 changed files with 26 additions and 0 deletions

View File

@@ -65,6 +65,8 @@ public:
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
virtual bool CallOnInit();
virtual bool OnInit();
virtual bool OnInitGui();

View File

@@ -39,6 +39,7 @@
#import <AppKit/NSApplication.h>
#import <Foundation/NSRunLoop.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSAutoreleasePool.h>
// ----------------------------------------------------------------------------
// 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())