diff options
author | jmkiley <jordan.kiley@mapbox.com> | 2018-11-07 15:25:36 -0800 |
---|---|---|
committer | jmkiley <jordan.kiley@mapbox.com> | 2018-11-07 15:25:36 -0800 |
commit | 137f73444e2f8701d9f356008b8df66ceb5db96e (patch) | |
tree | 44ab3febb855b94fa3bfe69bdf9ccb0df89151f7 | |
parent | 4c7eeffa7e4a5cfea11431de8d1f55740c34a715 (diff) | |
download | qtlocation-mapboxgl-upstream/jmkiley-attribution-info-string.tar.gz |
[ios] check if on main queueupstream/jmkiley-attribution-info-string
-rw-r--r-- | platform/darwin/src/MGLAttributionInfo.mm | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm index 07b9195942..de18fe6f74 100644 --- a/platform/darwin/src/MGLAttributionInfo.mm +++ b/platform/darwin/src/MGLAttributionInfo.mm @@ -66,14 +66,19 @@ #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 |