Fix crash in passcode setup.

This commit is contained in:
John Preston 2019-03-04 22:40:21 +04:00
parent c27456277e
commit f4544b0964
3 changed files with 16 additions and 2 deletions

View File

@ -476,9 +476,17 @@ void AuthSession::saveSettingsDelayed(crl::time delay) {
_saveDataTimer.callOnce(delay);
}
void AuthSession::localPasscodeChanged() {
_shouldLockAt = 0;
_autoLockTimer.cancel();
checkAutoLock();
}
void AuthSession::checkAutoLock() {
if (!Global::LocalPasscode()
|| Core::App().passcodeLocked()) {
_shouldLockAt = 0;
_autoLockTimer.cancel();
return;
}
@ -487,6 +495,8 @@ void AuthSession::checkAutoLock() {
const auto shouldLockInMs = Global::AutoLock() * 1000LL;
const auto checkTimeMs = now - Core::App().lastNonIdleTime();
if (checkTimeMs >= shouldLockInMs || (_shouldLockAt > 0 && now > _shouldLockAt + kAutoLockTimeoutLateMs)) {
_shouldLockAt = 0;
_autoLockTimer.cancel();
Core::App().lockByPasscode();
} else {
_shouldLockAt = now + (shouldLockInMs - checkTimeMs);

View File

@ -316,6 +316,7 @@ public:
void checkAutoLock();
void checkAutoLockIn(crl::time time);
void localPasscodeChanged();
rpl::lifetime &lifetime() {
return _lifetime;

View File

@ -452,10 +452,13 @@ void PasscodeBox::save(bool force) {
changeCloudPassword(old, pwd);
}
} else {
const auto weak = make_weak(this);
cSetPasscodeBadTries(0);
Local::setPasscode(pwd.toUtf8());
Auth().checkAutoLock();
closeBox();
Auth().localPasscodeChanged();
if (weak) {
closeBox();
}
}
}