fixing the wrong project being non-arc.

Add a convinience function for running blocks on the main thread syncronously.

git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@86262 e17a0e51-4ae3-4d35-97c3-1a29b211df97
This commit is contained in:
SND\MaddTheSane_cp 2013-07-26 19:55:10 +00:00
parent 13e08db872
commit d663bbeb7c
6 changed files with 60 additions and 52 deletions

View File

@ -917,8 +917,8 @@
children = (
55858D2F178652F90068B8FC /* Configs */,
08FB7795FE84155DC02AAC07 /* PCSXR */,
551A749D17868B110052D185 /* Frameworks */,
551A74AF17868BE90052D185 /* plugins */,
551A749D17868B110052D185 /* Frameworks */,
1AB674ADFE9D54B511CA2CBB /* Products */,
2BB3D6CF05427FE200831ACB /* Info.plist */,
);
@ -2998,7 +2998,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
"CLANG_ENABLE_OBJC_ARC[arch=x86_64]" = NO;
CLANG_WARN_EMPTY_BODY = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@ -3017,7 +3016,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
"CLANG_ENABLE_OBJC_ARC[arch=x86_64]" = NO;
CLANG_WARN_EMPTY_BODY = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@ -3144,6 +3142,7 @@
551A77C21786A2890052D185 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CLANG_ENABLE_OBJC_ARC[arch=x86_64]" = NO;
CLANG_WARN_EMPTY_BODY = YES;
DYLIB_COMPATIBILITY_VERSION = 150.2.50;
DYLIB_CURRENT_VERSION = 24;
@ -3163,6 +3162,7 @@
551A77C31786A2890052D185 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CLANG_ENABLE_OBJC_ARC[arch=x86_64]" = NO;
CLANG_WARN_EMPTY_BODY = YES;
DYLIB_COMPATIBILITY_VERSION = 150.2.50;
DYLIB_CURRENT_VERSION = 24;
@ -3231,7 +3231,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
"CLANG_ENABLE_OBJC_ARC[arch=x86_64]" = NO;
CLANG_WARN_EMPTY_BODY = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@ -3248,6 +3247,7 @@
557649BC1786B09E007C4457 /* Instrument */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CLANG_ENABLE_OBJC_ARC[arch=x86_64]" = NO;
CLANG_WARN_EMPTY_BODY = YES;
DYLIB_COMPATIBILITY_VERSION = 150.2.50;
DYLIB_CURRENT_VERSION = 24;

View File

@ -18,6 +18,15 @@
#import "hotkeys.h"
#import "ARCBridge.h"
static inline void RunOnMainThreadSync(dispatch_block_t block)
{
if ([NSThread isMainThread]) {
block();
} else {
dispatch_sync(dispatch_get_main_queue(), block);
}
}
static BOOL sysInited = NO;
//#define EMU_LOG
static IOPMAssertionID powerAssertion = kIOPMNullAssertionID;
@ -129,22 +138,16 @@ void SysPrintf(const char *fmt, ...) {
va_start(list, fmt);
vsnprintf(msg, 512, fmt, list);
va_end(list);
dispatch_block_t printfBlock = ^{
RunOnMainThreadSync(^{
if (Config.PsxOut) NSLog (@"%s", msg);
#ifdef EMU_LOG
#ifndef LOG_STDOUT
if (emuLog) fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"] UTF8String], msg);
[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"] UTF8String], msg);
#endif
#endif
};
if ([NSThread isMainThread]) {
printfBlock();
} else {
dispatch_sync(dispatch_get_main_queue(), printfBlock);
}
});
free(msg);
}
@ -160,16 +163,9 @@ void SysMessage(const char *fmt, ...) {
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:msg forKey:NSLocalizedFailureReasonErrorKey];
RELEASEOBJ(msg);
dispatch_block_t sysBlock = ^{
RunOnMainThreadSync(^{
[NSApp presentError:[NSError errorWithDomain:@"Unknown Domain" code:-1 userInfo:userInfo]];
};
if ([NSThread isMainThread]) {
sysBlock();
} else {
dispatch_sync(dispatch_get_main_queue(), sysBlock);
}
});
}
void *SysLoadLibrary(const char *lib) {

View File

@ -12,31 +12,33 @@
*/
FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
{
@autoreleasepool {
FILE* fp = NULL;
// If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only.
if(strcmp("r", mode) && strcmp("rb", mode))
{
return fopen(file, mode);
}
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
{
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
}
else
{
fp = fopen(file, mode);
}
return fp;
FILE* fp = NULL;
// If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only.
if(strcmp("r", mode) && strcmp("rb", mode))
{
return fopen(file, mode);
}
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
{
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
}
else
{
fp = fopen(file, mode);
}
[pool drain];
return fp;
}
#endif

View File

@ -40,12 +40,20 @@ void SysMessage(const char *fmt, ...)
}
}
static inline void RunOnMainThreadSync(dispatch_block_t block)
{
if ([NSThread isMainThread]) {
block();
} else {
dispatch_sync(dispatch_get_main_queue(), block);
}
}
static SockDialog *globalSock = nil;
void sockCreateWaitDlg()
{
dispatch_sync(dispatch_get_main_queue(), ^{
RunOnMainThreadSync(^{
if (globalSock == nil) {
globalSock = [[SockDialog alloc] init];
}
@ -70,7 +78,7 @@ long sockOpen()
void sockDestroyWaitDlg()
{
dispatch_sync(dispatch_get_main_queue(), ^{
RunOnMainThreadSync(^{
if (globalSock != nil) {
[globalSock close];

View File

@ -66,7 +66,7 @@ void AboutDlgProc()
[icon setSize:size];
NSDictionary *infoPaneDict =
[NSDictionary dictionaryWithObjectsAndKeys:
[[NSDictionary alloc] initWithObjectsAndKeys:
[bundle objectForInfoDictionaryKey:@"CFBundleName"], @"ApplicationName",
icon, @"ApplicationIcon",
[bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"ApplicationVersion",
@ -77,6 +77,7 @@ void AboutDlgProc()
dispatch_async(dispatch_get_main_queue(), ^{
[app orderFrontStandardAboutPanelWithOptions:infoPaneDict];
});
RELEASEOBJ(infoPaneDict);
}
void SoftDlgProc()

View File

@ -71,7 +71,7 @@ void AboutDlgProc()
[icon setSize:size];
NSDictionary *infoPaneDict =
[NSDictionary dictionaryWithObjectsAndKeys:
[[NSDictionary alloc] initWithObjectsAndKeys:
[bundle objectForInfoDictionaryKey:@"CFBundleName"], @"ApplicationName",
icon, @"ApplicationIcon",
[bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"ApplicationVersion",
@ -82,6 +82,7 @@ void AboutDlgProc()
dispatch_async(dispatch_get_main_queue(), ^{
[app orderFrontStandardAboutPanelWithOptions:infoPaneDict];
});
RELEASEOBJ(infoPaneDict);
}
void DlgProc()