[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.
This commit is contained in:
@@ -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];
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user