summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLOfflinePack.mm
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 14:22:55 -0700
commit8b713d937343c8c4aafb1387279c1eec11e5ab95 (patch)
treed55b15cb7309e743db3f4e637cc92cfb3c207006 /platform/darwin/src/MGLOfflinePack.mm
parentea59ba8209604c91b76abb31e6be15932bcb3430 (diff)
downloadqtlocation-mapboxgl-8b713d937343c8c4aafb1387279c1eec11e5ab95.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.
Diffstat (limited to 'platform/darwin/src/MGLOfflinePack.mm')
-rw-r--r--platform/darwin/src/MGLOfflinePack.mm9
1 files changed, 6 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];
});
}