[Scummvm-git-logs] scummvm master -> 71728d302a938fa8e9ec6ecb1293d4bb5ec82738

criezy criezy at scummvm.org
Wed Sep 22 22:27:57 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
71728d302a IOS7: Fix calling UI API on a background thread


Commit: 71728d302a938fa8e9ec6ecb1293d4bb5ec82738
    https://github.com/scummvm/scummvm/commit/71728d302a938fa8e9ec6ecb1293d4bb5ec82738
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-09-22T23:26:18+01:00

Commit Message:
IOS7: Fix calling UI API on a background thread

This is a genealization of commit 0d8b9d272 that only fixed the
issue for some cases. The issue still occured when suspending the
app for example.

Changed paths:
    backends/platform/ios7/ios7_app_delegate.mm
    backends/platform/ios7/ios7_osys_video.mm


diff --git a/backends/platform/ios7/ios7_app_delegate.mm b/backends/platform/ios7/ios7_app_delegate.mm
index 8837087e67..1330013ffa 100644
--- a/backends/platform/ios7/ios7_app_delegate.mm
+++ b/backends/platform/ios7/ios7_app_delegate.mm
@@ -121,7 +121,16 @@
 
 + (iOS7AppDelegate *)iOS7AppDelegate {
 	UIApplication *app = [UIApplication sharedApplication];
-	return (iOS7AppDelegate *) app.delegate;
+	// [UIApplication delegate] must be used from the main thread only
+	if ([NSThread currentThread] == [NSThread mainThread]) {
+		return (iOS7AppDelegate *) app.delegate;
+	} else {
+		__block iOS7AppDelegate *delegate = nil;
+		dispatch_sync(dispatch_get_main_queue(), ^{
+			delegate = (iOS7AppDelegate *) app.delegate;
+		});
+		return delegate;
+	}
 }
 
 + (iPhoneView *)iPhoneView {
diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm
index 1f186b3dc9..d304a249b9 100644
--- a/backends/platform/ios7/ios7_osys_video.mm
+++ b/backends/platform/ios7/ios7_osys_video.mm
@@ -597,13 +597,5 @@ void OSystem_iOS7::setShowKeyboard(bool show) {
 }
 
 bool OSystem_iOS7::isKeyboardShown() const {
-	if ([NSThread currentThread] == [NSThread mainThread]) {
-		return [[iOS7AppDelegate iPhoneView] isKeyboardShown];
-	} else {
-		__block bool shown = false;
-		dispatch_sync(dispatch_get_main_queue(), ^{
-			 shown = [[iOS7AppDelegate iPhoneView] isKeyboardShown];
-		});
-		return shown;
-	}
+	return [[iOS7AppDelegate iPhoneView] isKeyboardShown];
 }




More information about the Scummvm-git-logs mailing list