Cleanup autorelease pools. Only make one (I don't think that one is even necessary since nothing should be using autoreleased objects, but just in case).

This commit is contained in:
Steve Checkoway
2008-03-21 11:11:00 +00:00
parent 0a37c9eb60
commit 918d5a3ccf
@@ -9,6 +9,7 @@
@public @public
NSWindow *m_window; NSWindow *m_window;
NSTextView *m_text; NSTextView *m_text;
NSAutoreleasePool *m_Pool;
} }
- (void) setupWindow:(NSImage *)image; - (void) setupWindow:(NSImage *)image;
@end @end
@@ -88,8 +89,9 @@ LoadingWindow_Cocoa::LoadingWindow_Cocoa()
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSImage *image = nil; NSImage *image = nil;
NSData *d = [NSData dataWithBytes:data.data() length:data.length()]; NSData *d = [[NSData alloc] initWithBytes:data.data() length:data.length()];
image = [[NSImage alloc] initWithData:d]; image = [[NSImage alloc] initWithData:d];
[d release];
if( !image ) if( !image )
{ {
[pool release]; [pool release];
@@ -97,16 +99,16 @@ LoadingWindow_Cocoa::LoadingWindow_Cocoa()
} }
g_helper = [[LoadingWindowHelper alloc] init]; g_helper = [[LoadingWindowHelper alloc] init];
g_helper->m_Pool = pool;
[g_helper performSelectorOnMainThread:@selector(setupWindow:) withObject:image waitUntilDone:YES]; [g_helper performSelectorOnMainThread:@selector(setupWindow:) withObject:image waitUntilDone:YES];
[image release];
[pool release];
} }
LoadingWindow_Cocoa::~LoadingWindow_Cocoa() LoadingWindow_Cocoa::~LoadingWindow_Cocoa()
{ {
if( !g_helper ) if( !g_helper )
return; return;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = g_helper->m_Pool;
[g_helper->m_window performSelectorOnMainThread:@selector(close) withObject:nil waitUntilDone:YES]; [g_helper->m_window performSelectorOnMainThread:@selector(close) withObject:nil waitUntilDone:YES];
[g_helper release]; [g_helper release];
g_helper = nil; g_helper = nil;
@@ -117,10 +119,9 @@ void LoadingWindow_Cocoa::SetText( RString str )
{ {
if( !g_helper ) if( !g_helper )
return; return;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *s = [[NSString alloc] initWithUTF8String:str];
NSString *s = [NSString stringWithUTF8String:str];
[g_helper->m_text performSelectorOnMainThread:@selector(setString:) withObject:(s ? s : @"") waitUntilDone:NO]; [g_helper->m_text performSelectorOnMainThread:@selector(setString:) withObject:(s ? s : @"") waitUntilDone:NO];
[pool release]; [s release];
} }
/* /*