Merge pull request #3683 from igrechuhin/crash

[ios] Added osmUserName checks to prevent crashes.
This commit is contained in:
Vlad Mihaylenko 2016-06-29 01:24:56 -07:00 committed by GitHub
commit b387f6eb5a

View file

@ -158,7 +158,9 @@ using namespace osm_auth_ios;
- (void)logout
{
[Statistics logEvent:kStatEventName(kStatAuthorization, kStatLogout)];
GetFramework().DropUserStats(OSMUserName().UTF8String);
NSString * osmUserName = OSMUserName();
if (osmUserName.length > 0)
GetFramework().DropUserStats(osmUserName.UTF8String);
AuthorizationStoreCredentials({});
[self.navigationController popViewControllerAnimated:YES];
}
@ -169,15 +171,17 @@ using namespace osm_auth_ios;
__weak auto weakSelf = self;
auto const policy = force ? editor::UserStatsLoader::UpdatePolicy::Force
: editor::UserStatsLoader::UpdatePolicy::Lazy;
GetFramework().UpdateUserStats(OSMUserName().UTF8String, policy, ^
{
[weakSelf updateUI];
});
NSString * osmUserName = OSMUserName();
if (osmUserName.length > 0)
GetFramework().UpdateUserStats(osmUserName.UTF8String, policy, ^{ [weakSelf updateUI]; });
}
- (void)updateUI
{
editor::UserStats stats = GetFramework().GetUserStats(OSMUserName().UTF8String);
NSString * osmUserName = OSMUserName();
if (osmUserName.length == 0)
return;
editor::UserStats stats = GetFramework().GetUserStats(osmUserName.UTF8String);
if (!stats)
return;
int32_t changesCount;