diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-03-09 15:57:21 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-03-10 17:14:14 -0800 |
commit | 7fa3b92429185eb3749c9f547839712c8a0faf2b (patch) | |
tree | 89de99fa34cc6f17ee1bf85961defc372384cc0b /platform/darwin/src/MGLOfflineStorage.mm | |
parent | 77d99584cec58ea2c6c8b58257ca5e13d0c02834 (diff) | |
download | qtlocation-mapboxgl-7fa3b92429185eb3749c9f547839712c8a0faf2b.tar.gz |
[ios, osx] Tightened offline task state
Fixed a race condition that could occur if a progress update comes after a call to remove the task but before the removal is complete. Avoid synchronously setting the task’s state inside -resume and -suspend; instead, rely on the observer to set the state asynchronously.
Diffstat (limited to 'platform/darwin/src/MGLOfflineStorage.mm')
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.mm | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index 274cef7688..b245273954 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -104,8 +104,9 @@ } - (void)removeTask:(MGLOfflineTask *)task withCompletionHandler:(MGLOfflineTaskRemovalCompletionHandler)completion { + mbgl::OfflineRegion *mbglOfflineRegion = task.mbglOfflineRegion; [task invalidate]; - self.mbglFileSource->deleteOfflineRegion(std::move(*task.mbglOfflineRegion), [&, task, completion](std::exception_ptr exception) { + self.mbglFileSource->deleteOfflineRegion(std::move(*mbglOfflineRegion), [&, completion](std::exception_ptr exception) { NSError *error; if (exception) { error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{ @@ -113,7 +114,7 @@ }]; } if (completion) { - dispatch_async(dispatch_get_main_queue(), [&, task, completion, error](void) { + dispatch_async(dispatch_get_main_queue(), [&, completion, error](void) { completion(error); }); } |