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

Guard against over calling pause or resume #8465

Merged
merged 2 commits into from
Mar 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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