diff options
Diffstat (limited to 'backends/platform/ios7/ios7_video.mm')
| -rw-r--r-- | backends/platform/ios7/ios7_video.mm | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm index 5baa83e8e8..85a4dc91d8 100644 --- a/backends/platform/ios7/ios7_video.mm +++ b/backends/platform/ios7/ios7_video.mm @@ -55,16 +55,31 @@ bool iOS7_isBigDevice() { return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad; } +static inline void execute_on_main_thread(void (^block)(void)) { + if ([NSThread currentThread] == [NSThread mainThread]) { + block(); + } + else { + dispatch_sync(dispatch_get_main_queue(), block); + } +} + void iOS7_updateScreen() { //printf("Mouse: (%i, %i)\n", mouseX, mouseY); if (!g_needsScreenUpdate) { g_needsScreenUpdate = 1; - [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; + execute_on_main_thread(^{ + [[iOS7AppDelegate iPhoneView] updateSurface]; + }); } } bool iOS7_fetchEvent(InternalEvent *event) { - return [[iOS7AppDelegate iPhoneView] fetchEvent:event]; + __block bool fetched; + execute_on_main_thread(^{ + fetched = [[iOS7AppDelegate iPhoneView] fetchEvent:event]; + }); + return fetched; } uint getSizeNextPOT(uint size) { |
