Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Guard against over calling pause or resume
Browse files Browse the repository at this point in the history
  • Loading branch information
boundsj authored Mar 19, 2017
1 parent e4981d5 commit 73ed8aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 0 additions & 3 deletions include/mbgl/storage/default_file_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ class DefaultFileSource : public FileSource {
*
* If pause is called then no revalidation or network request activity
* will occur.
*
* Note: Calling pause and then calling getAPIBaseURL or getAccessToken
* will lock the thread that those calls are made on.
*/
void pause();

Expand Down
9 changes: 9 additions & 0 deletions platform/darwin/src/MGLOfflineStorage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ @interface MGLOfflineStorage ()

@property (nonatomic, strong, readwrite) NS_MUTABLE_ARRAY_OF(MGLOfflinePack *) *packs;
@property (nonatomic) mbgl::DefaultFileSource *mbglFileSource;
@property (nonatomic, getter=isPaused) BOOL paused;

@end

Expand All @@ -53,11 +54,19 @@ + (instancetype)sharedOfflineStorage {

#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
- (void)pauseFileSource:(__unused NSNotification *)notification {
if (self.isPaused) {
return;
}
_mbglFileSource->pause();
self.paused = YES;
}

- (void)unpauseFileSource:(__unused NSNotification *)notification {
if (!self.isPaused) {
return;
}
_mbglFileSource->resume();
self.paused = NO;
}
#endif

Expand Down

0 comments on commit 73ed8aa

Please sign in to comment.