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
This commit is contained in:
Soren Jorvang
2010-07-09 22:31:04 +00:00
parent 1e4f3c589d
commit 2bcdf4f5a4
7 changed files with 39 additions and 137 deletions

View File

@ -257,7 +257,6 @@ env['HAVE_WX'] = 0
# OS X specifics # OS X specifics
if sys.platform == 'darwin': if sys.platform == 'darwin':
compileFlags.append('-mmacosx-version-min=10.5') compileFlags.append('-mmacosx-version-min=10.5')
cppDefines.append('MAP_32BIT=0')
if not env['nowx']: if not env['nowx']:
cppDefines.append('HAVE_WX=1') cppDefines.append('HAVE_WX=1')
conf = env.Configure(custom_tests = tests) conf = env.Configure(custom_tests = tests)
@ -322,10 +321,9 @@ if not sys.platform == 'win32' and not sys.platform == 'darwin':
wxmods.remove('gl') wxmods.remove('gl')
env['HAVE_WX'] = conf.CheckWXConfig(2.8, wxmods, 0) env['HAVE_WX'] = conf.CheckWXConfig(2.8, wxmods, 0)
wxconfig.ParseWXConfig(env) wxconfig.ParseWXConfig(env)
if not env['HAVE_WX']:
if not env['HAVE_WX'] and not env['nowx']: print "WX libraries not found - see config.log"
print "WX libraries not found - see config.log" Exit(1)
Exit(1)
conf.Define('HAVE_WX', env['HAVE_WX']) conf.Define('HAVE_WX', env['HAVE_WX'])

View File

@ -113,6 +113,7 @@ extern const char *netplay_dolphin_ver;
#ifdef __APPLE__ #ifdef __APPLE__
#if defined HAVE_WX && HAVE_WX #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 #define USE_WX 1 // Use wxGLCanvas
#endif // HAVE_WX #endif // HAVE_WX
#else // __APPLE__ #else // __APPLE__

View File

@ -322,14 +322,13 @@ int appleMain(int argc, char *argv[]);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
cocoaArgc = argc; cocoaArgc = argc;
cocoaArgv = argv; cocoaArgv = argv;
cocoaCreateApp(); cocoaCreateApp();
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CocoaThread *thread = [[CocoaThread alloc] init]; CocoaThread *thread = [[CocoaThread alloc] init];
NSEvent *event = [[NSEvent alloc] init]; NSEvent *event = [[NSEvent alloc] init];

View File

@ -3,7 +3,7 @@
@implementation NSApplication(i) @implementation NSApplication(i)
- (void)appRunning - (void)appRunning
{ {
_running = 1; _running = 1;
} }
@end @end
@ -14,22 +14,20 @@
@implementation cocoaAppDelegate : NSObject @implementation cocoaAppDelegate : NSObject
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{ {
return NSTerminateCancel; return NSTerminateCancel;
} }
@end @end
void cocoaCreateApp() void cocoaCreateApp()
{ {
ProcessSerialNumber psn; ProcessSerialNumber psn;
NSAutoreleasePool *pool;
if (!GetCurrentProcess(&psn)) { if (!GetCurrentProcess(&psn)) {
TransformProcessType(&psn, kProcessTransformToForegroundApplication); TransformProcessType(&psn,
kProcessTransformToForegroundApplication);
SetFrontProcess(&psn); SetFrontProcess(&psn);
} }
pool = [[NSAutoreleasePool alloc] init];
if (NSApp == nil) { if (NSApp == nil) {
[NSApplication sharedApplication]; [NSApplication sharedApplication];
//TODO : Create menu //TODO : Create menu
@ -41,16 +39,12 @@ void cocoaCreateApp()
} }
[NSApp appRunning]; [NSApp appRunning];
[pool release];
} }
bool cocoaKeyCode(NSEvent *event) bool cocoaKeyCode(NSEvent *event)
{ {
static bool CMDDown = false, QDown = false; static bool CMDDown = false, QDown = false;
bool Return = false; bool Return = false;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSConnection *connec = [[NSConnection new] autorelease]; NSConnection *connec = [[NSConnection new] autorelease];
@ -78,15 +72,11 @@ bool cocoaKeyCode(NSEvent *event)
if( QDown && CMDDown ) if( QDown && CMDDown )
Return = true; Return = true;
[pool release];
return Return; return Return;
} }
bool cocoaSendEvent(NSEvent *event) bool cocoaSendEvent(NSEvent *event)
{ {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
if ( event != nil ) { if ( event != nil ) {
switch ([event type]) { switch ([event type]) {
case NSKeyDown: case NSKeyDown:
@ -100,10 +90,5 @@ bool cocoaSendEvent(NSEvent *event)
} }
} }
[pool release];
return false; return false;
} }

View File

@ -1,39 +1,27 @@
#import "cocoaGL.h" #import "cocoaGL.h"
NSWindow *cocoaGLCreateWindow(int w,int h) NSWindow *cocoaGLCreateWindow(int w, int h)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *window; NSWindow *window;
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,50,w,h) window = [[NSWindow alloc] initWithContentRect: NSMakeRect(50, 50, w, h)
styleMask:NSTitledWindowMask | NSResizableWindowMask styleMask: NSTitledWindowMask | NSResizableWindowMask
backing:NSBackingStoreBuffered backing: NSBackingStoreBuffered defer: FALSE];
defer:FALSE];
[window setReleasedWhenClosed: YES]; [window setReleasedWhenClosed: YES];
[window setTitle:@"Dolphin on OSX"]; [window setTitle:@"Dolphin on OSX"];
//[window makeKeyAndOrderFront: nil]; //[window makeKeyAndOrderFront: nil];
[pool release];
return window; return window;
} }
void cocoaGLSetTitle(NSWindow *win, const char *title) void cocoaGLSetTitle(NSWindow *win, const char *title)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [win setTitle: [[[NSString alloc] initWithCString: title
encoding: NSASCIIStringEncoding] autorelease]];
[win setTitle: [[[NSString alloc] initWithCString: title encoding: NSASCIIStringEncoding] autorelease]];
[pool release];
} }
void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win) void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win)
{ {
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
int value = 0; int value = 0;
[ctx setValues:&value forParameter:NSOpenGLCPSwapInterval]; [ctx setValues:&value forParameter:NSOpenGLCPSwapInterval];
@ -41,35 +29,27 @@ void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win)
[ctx setView:[win contentView]]; [ctx setView:[win contentView]];
[ctx update]; [ctx update];
[ctx makeCurrentContext]; [ctx makeCurrentContext];
} }
else else
[NSOpenGLContext clearCurrentContext]; [NSOpenGLContext clearCurrentContext];
[pool release];
} }
NSOpenGLContext* cocoaGLInit(int mode) NSOpenGLContext* cocoaGLInit(int mode)
{ {
NSAutoreleasePool *pool;
NSOpenGLPixelFormatAttribute attr[32]; NSOpenGLPixelFormatAttribute attr[32];
NSOpenGLPixelFormat *fmt; NSOpenGLPixelFormat *fmt;
NSOpenGLContext *context; NSOpenGLContext *context;
int i = 0; int i = 0;
pool = [[NSAutoreleasePool alloc] init];
attr[i++] = NSOpenGLPFADepthSize; attr[i++] = NSOpenGLPFADepthSize;
attr[i++] = 24; attr[i++] = 24;
attr[i++] = NSOpenGLPFADoubleBuffer; attr[i++] = NSOpenGLPFADoubleBuffer;
attr[i++] = NSOpenGLPFASampleBuffers; attr[i++] = NSOpenGLPFASampleBuffers;
attr[i++] = mode; attr[i++] = mode;
attr[i++] = NSOpenGLPFASamples; attr[i++] = NSOpenGLPFASamples;
attr[i++] = 1; attr[i++] = 1;
attr[i++] = NSOpenGLPFANoRecovery; attr[i++] = NSOpenGLPFANoRecovery;
#ifdef GL_VERSION_1_3 #ifdef GL_VERSION_1_3
@ -87,9 +67,8 @@ NSOpenGLContext* cocoaGLInit(int mode)
attr[i] = 0; attr[i] = 0;
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
if (fmt == nil) { if (fmt == nil) {
printf("failed to create pixel format\n"); printf("failed to create pixel format\n");
[pool release];
return NULL; return NULL;
} }
@ -99,51 +78,32 @@ NSOpenGLContext* cocoaGLInit(int mode)
if (context == nil) { if (context == nil) {
printf("failed to create context\n"); printf("failed to create context\n");
[pool release];
return NULL; return NULL;
} }
[pool release];
return context; return context;
} }
void cocoaGLDelete(NSOpenGLContext *ctx) void cocoaGLDelete(NSOpenGLContext *ctx)
{ {
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
[ctx clearDrawable]; [ctx clearDrawable];
[ctx release]; [ctx release];
[pool release];
} }
void cocoaGLDeleteWindow(NSWindow *window) void cocoaGLDeleteWindow(NSWindow *window)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[window close]; [window close];
[pool release];
return; return;
} }
void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window) void cocoaGLSwap(NSOpenGLContext *ctx, NSWindow *window)
{ {
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
[window makeKeyAndOrderFront: nil]; [window makeKeyAndOrderFront: nil];
ctx = [NSOpenGLContext currentContext]; ctx = [NSOpenGLContext currentContext];
if (ctx != nil) if (ctx != nil)
[ctx flushBuffer]; [ctx flushBuffer];
else else
printf("bad cocoa gl ctx\n"); printf("bad cocoa gl ctx\n");
[pool release];
} }

View File

@ -1,39 +1,27 @@
#import "cocoaGL.h" #import "cocoaGL.h"
NSWindow *cocoaGLCreateWindow(int w,int h) NSWindow *cocoaGLCreateWindow(int w, int h)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *window; NSWindow *window;
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,50,w,h) window = [[NSWindow alloc] initWithContentRect: NSMakeRect(50, 50, w, h)
styleMask:NSTitledWindowMask | NSResizableWindowMask styleMask: NSTitledWindowMask | NSResizableWindowMask
backing:NSBackingStoreBuffered backing: NSBackingStoreBuffered defer: FALSE];
defer:FALSE];
[window setReleasedWhenClosed: YES]; [window setReleasedWhenClosed: YES];
[window setTitle:@"Dolphin on OSX"]; [window setTitle:@"Dolphin on OSX"];
//[window makeKeyAndOrderFront: nil]; //[window makeKeyAndOrderFront: nil];
[pool release];
return window; return window;
} }
void cocoaGLSetTitle(NSWindow *win, const char *title) void cocoaGLSetTitle(NSWindow *win, const char *title)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [win setTitle: [[[NSString alloc] initWithCString: title
encoding: NSASCIIStringEncoding] autorelease]];
[win setTitle: [[[NSString alloc] initWithCString: title encoding: NSASCIIStringEncoding] autorelease]];
[pool release];
} }
void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win) void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win)
{ {
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
int value = 0; int value = 0;
[ctx setValues:&value forParameter:NSOpenGLCPSwapInterval]; [ctx setValues:&value forParameter:NSOpenGLCPSwapInterval];
@ -41,35 +29,27 @@ void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win)
[ctx setView:[win contentView]]; [ctx setView:[win contentView]];
[ctx update]; [ctx update];
[ctx makeCurrentContext]; [ctx makeCurrentContext];
} }
else else
[NSOpenGLContext clearCurrentContext]; [NSOpenGLContext clearCurrentContext];
[pool release];
} }
NSOpenGLContext* cocoaGLInit(int mode) NSOpenGLContext* cocoaGLInit(int mode)
{ {
NSAutoreleasePool *pool;
NSOpenGLPixelFormatAttribute attr[32]; NSOpenGLPixelFormatAttribute attr[32];
NSOpenGLPixelFormat *fmt; NSOpenGLPixelFormat *fmt;
NSOpenGLContext *context; NSOpenGLContext *context;
int i = 0; int i = 0;
pool = [[NSAutoreleasePool alloc] init];
attr[i++] = NSOpenGLPFADepthSize; attr[i++] = NSOpenGLPFADepthSize;
attr[i++] = 24; attr[i++] = 24;
attr[i++] = NSOpenGLPFADoubleBuffer; attr[i++] = NSOpenGLPFADoubleBuffer;
attr[i++] = NSOpenGLPFASampleBuffers; attr[i++] = NSOpenGLPFASampleBuffers;
attr[i++] = mode; attr[i++] = mode;
attr[i++] = NSOpenGLPFASamples; attr[i++] = NSOpenGLPFASamples;
attr[i++] = 1; attr[i++] = 1;
attr[i++] = NSOpenGLPFANoRecovery; attr[i++] = NSOpenGLPFANoRecovery;
#ifdef GL_VERSION_1_3 #ifdef GL_VERSION_1_3
@ -87,9 +67,8 @@ NSOpenGLContext* cocoaGLInit(int mode)
attr[i] = 0; attr[i] = 0;
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
if (fmt == nil) { if (fmt == nil) {
printf("failed to create pixel format\n"); printf("failed to create pixel format\n");
[pool release];
return NULL; return NULL;
} }
@ -99,51 +78,32 @@ NSOpenGLContext* cocoaGLInit(int mode)
if (context == nil) { if (context == nil) {
printf("failed to create context\n"); printf("failed to create context\n");
[pool release];
return NULL; return NULL;
} }
[pool release];
return context; return context;
} }
void cocoaGLDelete(NSOpenGLContext *ctx) void cocoaGLDelete(NSOpenGLContext *ctx)
{ {
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
[ctx clearDrawable]; [ctx clearDrawable];
[ctx release]; [ctx release];
[pool release];
} }
void cocoaGLDeleteWindow(NSWindow *window) void cocoaGLDeleteWindow(NSWindow *window)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[window close]; [window close];
[pool release];
return; return;
} }
void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window) void cocoaGLSwap(NSOpenGLContext *ctx, NSWindow *window)
{ {
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
[window makeKeyAndOrderFront: nil]; [window makeKeyAndOrderFront: nil];
ctx = [NSOpenGLContext currentContext]; ctx = [NSOpenGLContext currentContext];
if (ctx != nil) if (ctx != nil)
[ctx flushBuffer]; [ctx flushBuffer];
else else
printf("bad cocoa gl ctx\n"); printf("bad cocoa gl ctx\n");
[pool release];
} }

View File

@ -11,7 +11,6 @@ files = [
'WiimoteEmu/Attachment/Classic.cpp', 'WiimoteEmu/Attachment/Classic.cpp',
'WiimoteEmu/Attachment/Attachment.cpp', 'WiimoteEmu/Attachment/Attachment.cpp',
'WiimoteEmu/Attachment/Nunchuk.cpp', 'WiimoteEmu/Attachment/Nunchuk.cpp',
'WiimoteEmu/Attachment/UDPNunchuk.cpp',
'WiimoteEmu/Attachment/Drums.cpp', 'WiimoteEmu/Attachment/Drums.cpp',
'WiimoteEmu/Attachment/Guitar.cpp', 'WiimoteEmu/Attachment/Guitar.cpp',
'WiimoteEmu/EmuSubroutines.cpp', 'WiimoteEmu/EmuSubroutines.cpp',