diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-01-14 22:10:02 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-01-14 22:10:02 +0000 |
| commit | f04fe325fc0bc79969fe46eca16898aa04e139ed (patch) | |
| tree | 05721515c2ba1e82772a61b04da3fa9ada2cfcf5 | |
| parent | fba17b7792445b0e97f4c10952950b4546b27f90 (diff) | |
| download | pcsxr-f04fe325fc0bc79969fe46eca16898aa04e139ed.tar.gz | |
Make sPluginList in PluginList.m unsafe-unretained so we can properly free it when other sources are done with it.
I didn't notice that the OS X app controller had a PluginList instance variable: use that instead of calling +[PluginList list].
A few other minor changes.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@82281 e17a0e51-4ae3-4d35-97c3-1a29b211df97
| -rwxr-xr-x | macosx/PcsxrController.m | 12 | ||||
| -rwxr-xr-x | macosx/PcsxrPlugin.m | 62 | ||||
| -rwxr-xr-x | macosx/PluginList.m | 24 |
3 files changed, 52 insertions, 46 deletions
diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m index d312dd07..233dbb87 100755 --- a/macosx/PcsxrController.m +++ b/macosx/PcsxrController.m @@ -6,7 +6,6 @@ #import "PcsxrPluginHandler.h" #import "PcsxrDiscHandler.h" #import "PcsxrFreezeStateHandler.h" -#import "PluginList.h" #include "psxcommon.h" #include "plugins.h" #include "misc.h" @@ -111,9 +110,9 @@ NSString *saveStatePath; { SetIsoFile(NULL); if ([[NSUserDefaults standardUserDefaults] boolForKey:@"NetPlay"]) { - [[PluginList list] enableNetPlug]; + [pluginList enableNetPlug]; } else { - [[PluginList list] disableNetPlug]; + [pluginList disableNetPlug]; } [EmuThread run]; } @@ -137,7 +136,7 @@ NSString *saveStatePath; - (IBAction)runBios:(id)sender { SetIsoFile(NULL); - [[PluginList list] disableNetPlug]; + [pluginList disableNetPlug]; [EmuThread runBios]; } @@ -148,9 +147,9 @@ NSString *saveStatePath; SetIsoFile([[url path] fileSystemRepresentation]); } else { if ([[NSUserDefaults standardUserDefaults] boolForKey:@"NetPlay"]) { - [[PluginList list] enableNetPlug]; + [pluginList enableNetPlug]; } else { - [[PluginList list] disableNetPlug]; + [pluginList disableNetPlug]; } SetIsoFile((const char *)[[url path] fileSystemRepresentation]); [EmuThread run]; @@ -287,7 +286,6 @@ NSString *saveStatePath; + (void)setConfigFromDefaults { - NSEnumerator *enumerator; const char *str; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; diff --git a/macosx/PcsxrPlugin.m b/macosx/PcsxrPlugin.m index 46fdaa0b..baa5e626 100755 --- a/macosx/PcsxrPlugin.m +++ b/macosx/PcsxrPlugin.m @@ -36,7 +36,7 @@ case PSE_LT_SPU: case PSE_LT_PAD: case PSE_LT_NET: - return [NSString stringWithFormat:@"Plugin%@", [PcsxrPlugin prefixForType:aType]]; + return [NSString stringWithFormat:@"Plugin%@", [self prefixForType:aType]]; break; default: return @""; @@ -68,27 +68,29 @@ static NSArray *returnArray = nil; if (returnArray == nil) { - NSURL *supportURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; - NSURL *libraryURL = [[NSFileManager defaultManager] URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; - NSURL *localSupportURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSLocalDomainMask appropriateForURL:nil create:YES error:NULL]; - NSURL *localLibraryURL = [[NSFileManager defaultManager] URLForDirectory:NSLibraryDirectory inDomain:NSLocalDomainMask appropriateForURL:nil create:YES error:NULL]; - - NSMutableArray *mutArray = [NSMutableArray arrayWithCapacity:5]; - - [mutArray addObject:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:Config.PluginsDir length:strlen(Config.PluginsDir)]]; - NSURL *url = [localLibraryURL URLByAppendingPathComponent:@"Playstation Emulator Plugins"]; - if ([url checkResourceIsReachableAndReturnError:NULL]) - [mutArray addObject:[url path]]; - url = [[localSupportURL URLByAppendingPathComponent:@"Pcsxr"] URLByAppendingPathComponent:@"PlugIns"]; - if ([url checkResourceIsReachableAndReturnError:NULL]) - [mutArray addObject:[url path]]; - url = [libraryURL URLByAppendingPathComponent:@"Playstation Emulator Plugins"]; - if ([url checkResourceIsReachableAndReturnError:NULL]) - [mutArray addObject:[url path]]; - url = [[supportURL URLByAppendingPathComponent:@"Pcsxr"] URLByAppendingPathComponent:@"PlugIns"]; - if ([url checkResourceIsReachableAndReturnError:NULL]) - [mutArray addObject:[url path]]; - returnArray = [[NSArray alloc] initWithArray:mutArray]; + @autoreleasepool { + NSURL *supportURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; + NSURL *libraryURL = [[NSFileManager defaultManager] URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; + NSURL *localSupportURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSLocalDomainMask appropriateForURL:nil create:YES error:NULL]; + NSURL *localLibraryURL = [[NSFileManager defaultManager] URLForDirectory:NSLibraryDirectory inDomain:NSLocalDomainMask appropriateForURL:nil create:YES error:NULL]; + + NSMutableArray *mutArray = [NSMutableArray arrayWithCapacity:5]; + + [mutArray addObject:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:Config.PluginsDir length:strlen(Config.PluginsDir)]]; + NSURL *url = [localLibraryURL URLByAppendingPathComponent:@"Playstation Emulator Plugins"]; + if ([url checkResourceIsReachableAndReturnError:NULL]) + [mutArray addObject:[url path]]; + url = [[localSupportURL URLByAppendingPathComponent:@"Pcsxr"] URLByAppendingPathComponent:@"PlugIns"]; + if ([url checkResourceIsReachableAndReturnError:NULL]) + [mutArray addObject:[url path]]; + url = [libraryURL URLByAppendingPathComponent:@"Playstation Emulator Plugins"]; + if ([url checkResourceIsReachableAndReturnError:NULL]) + [mutArray addObject:[url path]]; + url = [[supportURL URLByAppendingPathComponent:@"Pcsxr"] URLByAppendingPathComponent:@"PlugIns"]; + if ([url checkResourceIsReachableAndReturnError:NULL]) + [mutArray addObject:[url path]]; + returnArray = [[NSArray alloc] initWithArray:mutArray]; + } } return returnArray; } @@ -191,7 +193,7 @@ } // save the current modification date - NSDictionary *fattrs = [[NSFileManager defaultManager] attributesOfItemAtPath:[goodPath stringByResolvingSymlinksInPath] error:NULL]; + NSDictionary *fattrs = [fm attributesOfItemAtPath:[goodPath stringByResolvingSymlinksInPath] error:NULL]; modDate = RETAINOBJ([fattrs fileModificationDate]); fullPlugPath = RETAINOBJ(goodPath); @@ -213,12 +215,14 @@ if (pluginRef) SysCloseLibrary(pluginRef); - RELEASEOBJ(modDate); - RELEASEOBJ(path); - RELEASEOBJ(name); - RELEASEOBJ(fullPlugPath); +#if !__has_feature(objc_arc) + [modDate release]; + [path release]; + [name release]; + [fullPlugPath release]; - SUPERDEALLOC; + [super dealloc]; +#endif } - (void)runCommand:(id)arg @@ -369,7 +373,7 @@ if (name == nil) { return fullPlugPath; } - return [NSString stringWithFormat:@"%@ %@ [%@]", name, [self displayVersion], fullPlugPath]; + return [NSString stringWithFormat:@"%@, %@ [%@]", name, [self displayVersion], fullPlugPath]; } // the plugin will check if it's still valid and return the status diff --git a/macosx/PluginList.m b/macosx/PluginList.m index 6fa341d9..813f0f58 100755 --- a/macosx/PluginList.m +++ b/macosx/PluginList.m @@ -14,7 +14,7 @@ #import "ARCBridge.h" //NSMutableArray *plugins; -static PluginList *sPluginList = nil; +static PluginList __unsafe_unretained *sPluginList = nil; const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD, PSE_LT_NET}; @implementation PluginList @@ -133,18 +133,22 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD, - (void)dealloc { - RELEASEOBJ(activeGpuPlugin); - RELEASEOBJ(activeSpuPlugin); - RELEASEOBJ(activeCdrPlugin); - RELEASEOBJ(activePadPlugin); - RELEASEOBJ(activeNetPlugin); - - RELEASEOBJ(pluginList); - if (sPluginList == self) sPluginList = nil; + +#if !__has_feature(objc_arc) + + [activeGpuPlugin release]; + [activeSpuPlugin release]; + [activeCdrPlugin release]; + [activePadPlugin release]; + [activeNetPlugin release]; - SUPERDEALLOC; + [pluginList release]; + + + [super dealloc]; +#endif } - (void)refreshPlugins |
