From 2bcdf4f5a476decb416a4947acc5472f9c011223 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Fri, 9 Jul 2010 22:31:04 +0000 Subject: [PATCH] Remove NSAutoreleasePools that are no longer necessary now that pools are properly declared at thread entry/exit. I am leaving the ones in Wiiuse while there's still a small hope that it may be used outside of Dolphin, though. Move the fixed MAP_32BIT definition for OS X to Common.h. UDPNunchuk.cpp was deleted, so update the scons build. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5864 8ced0084-cf51-0410-be5f-012b33b47a6e --- SConstruct | 8 +-- Source/Core/Common/Src/Common.h | 1 + Source/Core/DolphinWX/Src/MainNoGUI.cpp | 3 +- Source/Core/DolphinWX/Src/cocoaApp.m | 23 ++---- Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m | 70 ++++--------------- .../Plugin_VideoSoftware/Src/cocoaGL.m | 70 ++++--------------- .../Plugins/Plugin_WiimoteNew/Src/SConscript | 1 - 7 files changed, 39 insertions(+), 137 deletions(-) diff --git a/SConstruct b/SConstruct index 8ba452b7ec..6a09bc3ab3 100644 --- a/SConstruct +++ b/SConstruct @@ -257,7 +257,6 @@ env['HAVE_WX'] = 0 # OS X specifics if sys.platform == 'darwin': compileFlags.append('-mmacosx-version-min=10.5') - cppDefines.append('MAP_32BIT=0') if not env['nowx']: cppDefines.append('HAVE_WX=1') conf = env.Configure(custom_tests = tests) @@ -322,10 +321,9 @@ if not sys.platform == 'win32' and not sys.platform == 'darwin': wxmods.remove('gl') env['HAVE_WX'] = conf.CheckWXConfig(2.8, wxmods, 0) wxconfig.ParseWXConfig(env) - - if not env['HAVE_WX'] and not env['nowx']: - print "WX libraries not found - see config.log" - Exit(1) + if not env['HAVE_WX']: + print "WX libraries not found - see config.log" + Exit(1) conf.Define('HAVE_WX', env['HAVE_WX']) diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h index 37d153962e..033ab80438 100644 --- a/Source/Core/Common/Src/Common.h +++ b/Source/Core/Common/Src/Common.h @@ -113,6 +113,7 @@ extern const char *netplay_dolphin_ver; #ifdef __APPLE__ #if defined HAVE_WX && HAVE_WX +#define MAP_32BIT 0 // MAP_32BIT is a Linux-specific mmap(2) flag #define USE_WX 1 // Use wxGLCanvas #endif // HAVE_WX #else // __APPLE__ diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 84933a5db7..4af83d3df3 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -322,14 +322,13 @@ int appleMain(int argc, char *argv[]); int main(int argc, char *argv[]) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; cocoaArgc = argc; cocoaArgv = argv; cocoaCreateApp(); - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - CocoaThread *thread = [[CocoaThread alloc] init]; NSEvent *event = [[NSEvent alloc] init]; diff --git a/Source/Core/DolphinWX/Src/cocoaApp.m b/Source/Core/DolphinWX/Src/cocoaApp.m index 5c5402cf89..dfcc92f8da 100644 --- a/Source/Core/DolphinWX/Src/cocoaApp.m +++ b/Source/Core/DolphinWX/Src/cocoaApp.m @@ -3,7 +3,7 @@ @implementation NSApplication(i) - (void)appRunning { - _running = 1; + _running = 1; } @end @@ -14,22 +14,20 @@ @implementation cocoaAppDelegate : NSObject - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { - return NSTerminateCancel; + return NSTerminateCancel; } @end void cocoaCreateApp() { ProcessSerialNumber psn; - NSAutoreleasePool *pool; if (!GetCurrentProcess(&psn)) { - TransformProcessType(&psn, kProcessTransformToForegroundApplication); + TransformProcessType(&psn, + kProcessTransformToForegroundApplication); SetFrontProcess(&psn); } - pool = [[NSAutoreleasePool alloc] init]; - if (NSApp == nil) { [NSApplication sharedApplication]; //TODO : Create menu @@ -41,16 +39,12 @@ void cocoaCreateApp() } [NSApp appRunning]; - - [pool release]; - } bool cocoaKeyCode(NSEvent *event) { static bool CMDDown = false, QDown = false; bool Return = false; - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSConnection *connec = [[NSConnection new] autorelease]; @@ -78,15 +72,11 @@ bool cocoaKeyCode(NSEvent *event) if( QDown && CMDDown ) Return = true; - [pool release]; return Return; } bool cocoaSendEvent(NSEvent *event) { - - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - if ( event != nil ) { switch ([event type]) { case NSKeyDown: @@ -100,10 +90,5 @@ bool cocoaSendEvent(NSEvent *event) } } - - [pool release]; return false; - } - - diff --git a/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m b/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m index 6a821635e2..5209bf3647 100755 --- a/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m +++ b/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m @@ -1,39 +1,27 @@ #import "cocoaGL.h" -NSWindow *cocoaGLCreateWindow(int w,int h) +NSWindow *cocoaGLCreateWindow(int w, int h) { - - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSWindow *window; - window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,50,w,h) - styleMask:NSTitledWindowMask | NSResizableWindowMask - backing:NSBackingStoreBuffered - defer:FALSE]; + window = [[NSWindow alloc] initWithContentRect: NSMakeRect(50, 50, w, h) + styleMask: NSTitledWindowMask | NSResizableWindowMask + backing: NSBackingStoreBuffered defer: FALSE]; [window setReleasedWhenClosed: YES]; [window setTitle:@"Dolphin on OSX"]; //[window makeKeyAndOrderFront: nil]; - [pool release]; - return window; } void cocoaGLSetTitle(NSWindow *win, const char *title) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [win setTitle: [[[NSString alloc] initWithCString: title encoding: NSASCIIStringEncoding] autorelease]]; - - [pool release]; + [win setTitle: [[[NSString alloc] initWithCString: title + encoding: NSASCIIStringEncoding] autorelease]]; } void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win) { - NSAutoreleasePool *pool; - - pool = [[NSAutoreleasePool alloc] init]; - int value = 0; [ctx setValues:&value forParameter:NSOpenGLCPSwapInterval]; @@ -41,35 +29,27 @@ void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win) [ctx setView:[win contentView]]; [ctx update]; [ctx makeCurrentContext]; - } - else + } + else [NSOpenGLContext clearCurrentContext]; - - [pool release]; } - - NSOpenGLContext* cocoaGLInit(int mode) { - NSAutoreleasePool *pool; - NSOpenGLPixelFormatAttribute attr[32]; NSOpenGLPixelFormat *fmt; NSOpenGLContext *context; int i = 0; - pool = [[NSAutoreleasePool alloc] init]; - attr[i++] = NSOpenGLPFADepthSize; attr[i++] = 24; attr[i++] = NSOpenGLPFADoubleBuffer; - + attr[i++] = NSOpenGLPFASampleBuffers; attr[i++] = mode; attr[i++] = NSOpenGLPFASamples; attr[i++] = 1; - + attr[i++] = NSOpenGLPFANoRecovery; #ifdef GL_VERSION_1_3 @@ -87,9 +67,8 @@ NSOpenGLContext* cocoaGLInit(int mode) attr[i] = 0; fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; - if (fmt == nil) { + if (fmt == nil) { printf("failed to create pixel format\n"); - [pool release]; return NULL; } @@ -99,51 +78,32 @@ NSOpenGLContext* cocoaGLInit(int mode) if (context == nil) { printf("failed to create context\n"); - [pool release]; return NULL; } - [pool release]; - return context; - } void cocoaGLDelete(NSOpenGLContext *ctx) { - NSAutoreleasePool *pool; - - pool = [[NSAutoreleasePool alloc] init]; - [ctx clearDrawable]; [ctx release]; - - [pool release]; - } + void cocoaGLDeleteWindow(NSWindow *window) { - - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [window close]; - [pool release]; - + return; } -void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window) +void cocoaGLSwap(NSOpenGLContext *ctx, NSWindow *window) { - NSAutoreleasePool *pool; - - pool = [[NSAutoreleasePool alloc] init]; [window makeKeyAndOrderFront: nil]; ctx = [NSOpenGLContext currentContext]; - if (ctx != nil) + if (ctx != nil) [ctx flushBuffer]; else printf("bad cocoa gl ctx\n"); - - [pool release]; } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.m b/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.m index 6a821635e2..5209bf3647 100755 --- a/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.m +++ b/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.m @@ -1,39 +1,27 @@ #import "cocoaGL.h" -NSWindow *cocoaGLCreateWindow(int w,int h) +NSWindow *cocoaGLCreateWindow(int w, int h) { - - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSWindow *window; - window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,50,w,h) - styleMask:NSTitledWindowMask | NSResizableWindowMask - backing:NSBackingStoreBuffered - defer:FALSE]; + window = [[NSWindow alloc] initWithContentRect: NSMakeRect(50, 50, w, h) + styleMask: NSTitledWindowMask | NSResizableWindowMask + backing: NSBackingStoreBuffered defer: FALSE]; [window setReleasedWhenClosed: YES]; [window setTitle:@"Dolphin on OSX"]; //[window makeKeyAndOrderFront: nil]; - [pool release]; - return window; } void cocoaGLSetTitle(NSWindow *win, const char *title) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [win setTitle: [[[NSString alloc] initWithCString: title encoding: NSASCIIStringEncoding] autorelease]]; - - [pool release]; + [win setTitle: [[[NSString alloc] initWithCString: title + encoding: NSASCIIStringEncoding] autorelease]]; } void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win) { - NSAutoreleasePool *pool; - - pool = [[NSAutoreleasePool alloc] init]; - int value = 0; [ctx setValues:&value forParameter:NSOpenGLCPSwapInterval]; @@ -41,35 +29,27 @@ void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win) [ctx setView:[win contentView]]; [ctx update]; [ctx makeCurrentContext]; - } - else + } + else [NSOpenGLContext clearCurrentContext]; - - [pool release]; } - - NSOpenGLContext* cocoaGLInit(int mode) { - NSAutoreleasePool *pool; - NSOpenGLPixelFormatAttribute attr[32]; NSOpenGLPixelFormat *fmt; NSOpenGLContext *context; int i = 0; - pool = [[NSAutoreleasePool alloc] init]; - attr[i++] = NSOpenGLPFADepthSize; attr[i++] = 24; attr[i++] = NSOpenGLPFADoubleBuffer; - + attr[i++] = NSOpenGLPFASampleBuffers; attr[i++] = mode; attr[i++] = NSOpenGLPFASamples; attr[i++] = 1; - + attr[i++] = NSOpenGLPFANoRecovery; #ifdef GL_VERSION_1_3 @@ -87,9 +67,8 @@ NSOpenGLContext* cocoaGLInit(int mode) attr[i] = 0; fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; - if (fmt == nil) { + if (fmt == nil) { printf("failed to create pixel format\n"); - [pool release]; return NULL; } @@ -99,51 +78,32 @@ NSOpenGLContext* cocoaGLInit(int mode) if (context == nil) { printf("failed to create context\n"); - [pool release]; return NULL; } - [pool release]; - return context; - } void cocoaGLDelete(NSOpenGLContext *ctx) { - NSAutoreleasePool *pool; - - pool = [[NSAutoreleasePool alloc] init]; - [ctx clearDrawable]; [ctx release]; - - [pool release]; - } + void cocoaGLDeleteWindow(NSWindow *window) { - - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [window close]; - [pool release]; - + return; } -void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window) +void cocoaGLSwap(NSOpenGLContext *ctx, NSWindow *window) { - NSAutoreleasePool *pool; - - pool = [[NSAutoreleasePool alloc] init]; [window makeKeyAndOrderFront: nil]; ctx = [NSOpenGLContext currentContext]; - if (ctx != nil) + if (ctx != nil) [ctx flushBuffer]; else printf("bad cocoa gl ctx\n"); - - [pool release]; } diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/SConscript b/Source/Plugins/Plugin_WiimoteNew/Src/SConscript index ce717b340f..ca982c6a59 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/SConscript +++ b/Source/Plugins/Plugin_WiimoteNew/Src/SConscript @@ -11,7 +11,6 @@ files = [ 'WiimoteEmu/Attachment/Classic.cpp', 'WiimoteEmu/Attachment/Attachment.cpp', 'WiimoteEmu/Attachment/Nunchuk.cpp', - 'WiimoteEmu/Attachment/UDPNunchuk.cpp', 'WiimoteEmu/Attachment/Drums.cpp', 'WiimoteEmu/Attachment/Guitar.cpp', 'WiimoteEmu/EmuSubroutines.cpp',