summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-06-17 16:49:12 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-06-17 16:49:12 -0700
commitbf6a100801639f5a5c190fb43233a8e2cfb98dad (patch)
tree7e4f95bde8b0358a4a3dc9044435c252c5b85c9e /platform
parentdcbb5b2e4ed927b1eb1c9fca94ea09a6e66405e0 (diff)
downloadqtlocation-mapboxgl-bf6a100801639f5a5c190fb43233a8e2cfb98dad.tar.gz
Avoid null-change KVO notifications
If no access token is set in the Info.plist, avoid triggering a KVO notification about the access token changing. By the same token (heh), avoid pulling a C string out of the change dictionary if the access token is being nilled out.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLAccountManager.m5
-rw-r--r--platform/ios/MGLMapView.mm4
2 files changed, 7 insertions, 2 deletions
diff --git a/platform/ios/MGLAccountManager.m b/platform/ios/MGLAccountManager.m
index d391ea8818..710ddd3e38 100644
--- a/platform/ios/MGLAccountManager.m
+++ b/platform/ios/MGLAccountManager.m
@@ -21,7 +21,10 @@
if (shownInAppNumber) {
[MGLAccountManager sharedManager].mapboxMetricsEnabledSettingShownInApp = [shownInAppNumber boolValue];
}
- self.accessToken = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
+ NSString *accessToken = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
+ if (accessToken.length) {
+ self.accessToken = accessToken;
+ }
}
// Can be called from any thread.
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 40eeec0ec6..efb428cb5c 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -1290,7 +1290,9 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
if ([keyPath isEqualToString:@"accessToken"] && object == [MGLAccountManager sharedManager])
{
NSString *accessToken = change[NSKeyValueChangeNewKey];
- _mbglFileSource->setAccessToken(accessToken ? (std::string)[accessToken UTF8String] : "");
+ if (![accessToken isKindOfClass:[NSNull class]]) {
+ _mbglFileSource->setAccessToken((std::string)[accessToken UTF8String]);
+ }
}
}