diff options
author | Julian Rex <julian.rex@mapbox.com> | 2019-10-11 15:16:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-11 15:16:12 -0400 |
commit | a1f124c39442d76af77a5aa63bba5afa4f4d6d26 (patch) | |
tree | 266c783ff174d256934b3e596cedef6e62d70e35 /platform/darwin | |
parent | 2fb1e47b75c038f226397df7b790ba699b6e2dc8 (diff) | |
download | qtlocation-mapboxgl-a1f124c39442d76af77a5aa63bba5afa4f4d6d26.tar.gz |
[ios] Fix for iOS 9 crash (seen in simulator) (#15771)
* [ios] Fix for iOS 9 crash (seen in simulator)
* [ios] Update change log
* [ios, macos] Add #if around new function.
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLSDKMetricsManager.m | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLSDKMetricsManager.m b/platform/darwin/src/MGLSDKMetricsManager.m index 828fbcd505..0ef9ecda10 100644 --- a/platform/darwin/src/MGLSDKMetricsManager.m +++ b/platform/darwin/src/MGLSDKMetricsManager.m @@ -18,6 +18,23 @@ NSString* MGLStringFromMetricType(MGLMetricType metricType) { return eventName; } +// Taken verbatim from NXFreeArchInfo header documentation +#if TARGET_OS_IOS +static void MGLFreeArchInfo(const NXArchInfo *x) +{ + const NXArchInfo *p; + + p = NXGetAllArchInfos(); + while(p->name != NULL){ + if(x == p) + return; + p++; + } + free((char *)x->description); + free((NXArchInfo *)x); +} +#endif + @interface MGLMetricsManager() <MGLNetworkConfigurationMetricsDelegate> @property (strong, nonatomic) NSDictionary *metadata; @@ -54,7 +71,16 @@ NSString* MGLStringFromMetricType(MGLMetricType metricType) { if (localArchInfo) { abi = @(localArchInfo->description); - NXFreeArchInfo(localArchInfo); + + NSProcessInfo *processInfo = [NSProcessInfo processInfo]; + + // Although NXFreeArchInfo appears to be weakly linked, it does + // not have the weak_import attribute, so check the OS version. + if (&NXFreeArchInfo && [processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 0, 0}]) { + NXFreeArchInfo(localArchInfo); + } else { + MGLFreeArchInfo(localArchInfo); + } } } |