diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-26 19:55:10 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-26 19:55:10 +0000 |
| commit | d663bbeb7c6958388d515c196bc73956b574ffbb (patch) | |
| tree | 3093f1f1ecc383bfbef59a96e6e00056089daa46 /macosx/main.m | |
| parent | 13e08db872f4775ca23df12fcc03f1916ed9691e (diff) | |
| download | pcsxr-d663bbeb7c6958388d515c196bc73956b574ffbb.tar.gz | |
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
Diffstat (limited to 'macosx/main.m')
| -rwxr-xr-x | macosx/main.m | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/macosx/main.m b/macosx/main.m index 90771a93..5aaf13f2 100755 --- a/macosx/main.m +++ b/macosx/main.m @@ -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) { |
