summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Kiley <jmkiley@users.noreply.github.com>2018-11-14 11:13:13 -0800
committerGitHub <noreply@github.com>2018-11-14 11:13:13 -0800
commit8a40c62eed5900fa6d9715861e4059778e867afb (patch)
treed5ef092f1460f28ce5226b3cf151442c3b47b3cf
parenta3b02c2870219ffb12b2be42e5b595460ae8b1db (diff)
downloadqtlocation-mapboxgl-8a40c62eed5900fa6d9715861e4059778e867afb.tar.gz
[ios] Address bad access exception in `MGLAttributionInfo` (#13300) (#13365)
-rw-r--r--platform/darwin/src/MGLAttributionInfo.mm20
1 files changed, 12 insertions, 8 deletions
diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm
index 5fa121f5f8..b780b2ae0d 100644
--- a/platform/darwin/src/MGLAttributionInfo.mm
+++ b/platform/darwin/src/MGLAttributionInfo.mm
@@ -65,16 +65,20 @@
NSData *htmlData = [styledHTML dataUsingEncoding:NSUTF8StringEncoding];
#if TARGET_OS_IPHONE
-
__block NSMutableAttributedString *attributedString;
+ dispatch_block_t initialization = ^{
+ // This initializer should be called from a global or main queue. https://developer.apple.com/documentation/foundation/nsattributedstring/1524613-initwithdata
+ attributedString = [[NSMutableAttributedString alloc] initWithData:htmlData
+ options:options
+ documentAttributes:nil
+ error:NULL];
+ };
- dispatch_sync(dispatch_get_main_queue() , ^{
- // This initializer should be called from a global or main queue. https://developer.apple.com/documentation/foundation/nsattributedstring/1524613-initwithdata
- attributedString = [[NSMutableAttributedString alloc] initWithData:htmlData
- options:options
- documentAttributes:nil
- error:NULL];
- });
+ if (![[NSThread currentThread] isMainThread]) {
+ dispatch_sync(dispatch_get_main_queue(), initialization);
+ } else {
+ initialization();
+ }
#else
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithHTML:htmlData
options:options