aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Crozat2019-08-04 20:40:22 +0100
committerThierry Crozat2019-08-04 20:40:22 +0100
commitfa9651d1bb2d2852c1146498fc8b55be823f9031 (patch)
tree04f3ad19b5f1a12ab771da1edb7508fc75906af1
parent468c0f07431d3fb423ba697dcf906d9fbc149780 (diff)
downloadscummvm-rg350-fa9651d1bb2d2852c1146498fc8b55be823f9031.tar.gz
scummvm-rg350-fa9651d1bb2d2852c1146498fc8b55be823f9031.tar.bz2
scummvm-rg350-fa9651d1bb2d2852c1146498fc8b55be823f9031.zip
IOS7: Make sure openURL is executed on the main thread
-rw-r--r--backends/platform/ios7/ios7_osys_misc.mm18
1 files changed, 15 insertions, 3 deletions
diff --git a/backends/platform/ios7/ios7_osys_misc.mm b/backends/platform/ios7/ios7_osys_misc.mm
index d7743f8466..1f9232c12e 100644
--- a/backends/platform/ios7/ios7_osys_misc.mm
+++ b/backends/platform/ios7/ios7_osys_misc.mm
@@ -29,6 +29,14 @@
#include <SystemConfiguration/SCNetworkReachability.h>
#include "common/translation.h"
+static inline void execute_on_main_thread_async(void (^block)(void)) {
+ if ([NSThread currentThread] == [NSThread mainThread]) {
+ block();
+ } else {
+ dispatch_async(dispatch_get_main_queue(), block);
+ }
+}
+
Common::String OSystem_iOS7::getSystemLanguage() const {
NSString *locale = [[NSLocale currentLocale] localeIdentifier];
if (locale == nil)
@@ -79,11 +87,15 @@ bool OSystem_iOS7::openUrl(const Common::String &url) {
// The way to oipen a URL has changed in iOS 10. Check if the iOS 10 method is recognized
// and otherwise use the old method.
if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
- [application openURL:nsurl options:@{} completionHandler:nil];
- return true;
+ execute_on_main_thread_async(^ {
+ [application openURL:nsurl options:@{} completionHandler:nil];
+ });
} else {
- return [application openURL:nsurl];
+ execute_on_main_thread_async(^ {
+ [application openURL:nsurl];
+ });
}
+ return true;
}
bool OSystem_iOS7::isConnectionLimited() {