diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-05-02 12:34:50 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-05-02 13:44:38 -0700 |
commit | 1c22374eac69fb2f95b3f6a60e6bfed449508af0 (patch) | |
tree | 3b659a6d04b8201500d86a8ab17bc86d31dfb0e4 /platform/darwin/src/MGLOfflinePack.mm | |
parent | 7125ad995564641698ada76141b70aef6eea9520 (diff) | |
download | qtlocation-mapboxgl-1c22374eac69fb2f95b3f6a60e6bfed449508af0.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.mm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLOfflinePack.mm b/platform/darwin/src/MGLOfflinePack.mm index 60a7b55531..5e555d425e 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 MBGLOfflinePack *_pack = pack; dispatch_async(dispatch_get_main_queue(), ^{ - [pack offlineRegionStatusDidChange:status]; + [_pack offlineRegionStatusDidChange:status]; }); } void MBGLOfflineRegionObserver::responseError(mbgl::Response::Error error) { + __weak MBGLOfflinePack *_pack = pack; dispatch_async(dispatch_get_main_queue(), ^{ - [pack didReceiveError:MGLErrorFromResponseError(error)]; + [_pack didReceiveError:MGLErrorFromResponseError(error)]; }); } void MBGLOfflineRegionObserver::mapboxTileCountLimitExceeded(uint64_t limit) { + __weak MBGLOfflinePack *_pack = pack; dispatch_async(dispatch_get_main_queue(), ^{ - [pack didReceiveMaximumAllowedMapboxTiles:limit]; + [_pack didReceiveMaximumAllowedMapboxTiles:limit]; }); } |