[ios] Address bad access exception in MGLAttributionInfo (#13300)
* [ios] move creation of attributed string to global queue] * [ios] check if on main queue
This commit is contained in:
@@ -65,10 +65,20 @@
|
||||
NSData *htmlData = [styledHTML dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithData:htmlData
|
||||
options:options
|
||||
documentAttributes:nil
|
||||
error:NULL];
|
||||
__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];
|
||||
};
|
||||
|
||||
if (![[NSThread currentThread] isMainThread]) {
|
||||
dispatch_sync(dispatch_get_main_queue(), initialization);
|
||||
} else {
|
||||
initialization();
|
||||
}
|
||||
#else
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithHTML:htmlData
|
||||
options:options
|
||||
|
||||
Reference in New Issue
Block a user