[ios] Guard against over calling pause or resume

This commit is contained in:
Jesse Bounds
2017-03-18 19:09:45 -07:00
committed by GitHub
parent e4981d5bd0
commit 73ed8aa7be
2 changed files with 9 additions and 3 deletions

View File

@@ -120,9 +120,6 @@ public:
*
* 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();

View File

@@ -31,6 +31,7 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = MGLOfflinePackUserInfoK
@property (nonatomic, strong, readwrite) NS_MUTABLE_ARRAY_OF(MGLOfflinePack *) *packs;
@property (nonatomic) mbgl::DefaultFileSource *mbglFileSource;
@property (nonatomic, getter=isPaused) BOOL paused;
@end
@@ -53,11 +54,19 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = MGLOfflinePackUserInfoK
#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