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.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user