summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-05-02 12:34:50 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-05-02 16:36:37 -0700
commit0bd9eac1744124e135df03753baa7395917ccf23 (patch)
tree1d201ca9bbb7ff6501dd98cfdb2e92cfa1b3076f
parent8e200ae38736e402929c90a105db9ff6f7677c2a (diff)
downloadqtlocation-mapboxgl-0bd9eac1744124e135df03753baa7395917ccf23.tar.gz
[ios, macos] Avoid implicit capture of MBGLOfflineRegionObserver this pointer
MBGLOfflineRegionObserver is owned by the offline database thread, and might be destroyed by the time the dispatch_async completes. Instead of implicitly capturing this, capture a copy of the MBGLOfflinePack weak pointer.
-rw-r--r--platform/darwin/src/MGLOfflinePack.mm9
-rw-r--r--platform/ios/CHANGELOG.md4
2 files changed, 10 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLOfflinePack.mm b/platform/darwin/src/MGLOfflinePack.mm
index 60a7b55531..4653021a58 100644
--- a/platform/darwin/src/MGLOfflinePack.mm
+++ b/platform/darwin/src/MGLOfflinePack.mm
@@ -227,19 +227,22 @@ NSError *MGLErrorFromResponseError(mbgl::Response::Error error) {
@end
void MBGLOfflineRegionObserver::statusChanged(mbgl::OfflineRegionStatus status) {
+ __weak MGLOfflinePack *weakPack = pack;
dispatch_async(dispatch_get_main_queue(), ^{
- [pack offlineRegionStatusDidChange:status];
+ [weakPack offlineRegionStatusDidChange:status];
});
}
void MBGLOfflineRegionObserver::responseError(mbgl::Response::Error error) {
+ __weak MGLOfflinePack *weakPack = pack;
dispatch_async(dispatch_get_main_queue(), ^{
- [pack didReceiveError:MGLErrorFromResponseError(error)];
+ [weakPack didReceiveError:MGLErrorFromResponseError(error)];
});
}
void MBGLOfflineRegionObserver::mapboxTileCountLimitExceeded(uint64_t limit) {
+ __weak MGLOfflinePack *weakPack = pack;
dispatch_async(dispatch_get_main_queue(), ^{
- [pack didReceiveMaximumAllowedMapboxTiles:limit];
+ [weakPack didReceiveMaximumAllowedMapboxTiles:limit];
});
}
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index e7277a2e10..438186c2b9 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -2,6 +2,10 @@
Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started.
+## 3.7.7
+
+* Fixed a crash when removing an `MGLOfflinePack`. ([#6092](https://github.com/mapbox/mapbox-gl-native/issues/6092))
+
## 3.7.6 - March 12, 2018
* Fixed an issue where full-resolution tiles could fail to replace lower-resolution placeholders. ([#11227](https://github.com/mapbox/mapbox-gl-native/pull/11227))