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
This commit is contained in:
SND\MaddTheSane_cp 2013-01-14 22:10:02 +00:00
parent fba17b7792
commit f04fe325fc
3 changed files with 52 additions and 46 deletions

View File

@ -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];

View File

@ -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

View File

@ -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