mirror of https://github.com/procxx/kepka.git
				
				
				
			Fix crash in passcode setup.
This commit is contained in:
		
							parent
							
								
									c27456277e
								
							
						
					
					
						commit
						f4544b0964
					
				|  | @ -476,9 +476,17 @@ void AuthSession::saveSettingsDelayed(crl::time delay) { | ||||||
| 	_saveDataTimer.callOnce(delay); | 	_saveDataTimer.callOnce(delay); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void AuthSession::localPasscodeChanged() { | ||||||
|  | 	_shouldLockAt = 0; | ||||||
|  | 	_autoLockTimer.cancel(); | ||||||
|  | 	checkAutoLock(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void AuthSession::checkAutoLock() { | void AuthSession::checkAutoLock() { | ||||||
| 	if (!Global::LocalPasscode() | 	if (!Global::LocalPasscode() | ||||||
| 		|| Core::App().passcodeLocked()) { | 		|| Core::App().passcodeLocked()) { | ||||||
|  | 		_shouldLockAt = 0; | ||||||
|  | 		_autoLockTimer.cancel(); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -487,6 +495,8 @@ void AuthSession::checkAutoLock() { | ||||||
| 	const auto shouldLockInMs = Global::AutoLock() * 1000LL; | 	const auto shouldLockInMs = Global::AutoLock() * 1000LL; | ||||||
| 	const auto checkTimeMs = now - Core::App().lastNonIdleTime(); | 	const auto checkTimeMs = now - Core::App().lastNonIdleTime(); | ||||||
| 	if (checkTimeMs >= shouldLockInMs || (_shouldLockAt > 0 && now > _shouldLockAt + kAutoLockTimeoutLateMs)) { | 	if (checkTimeMs >= shouldLockInMs || (_shouldLockAt > 0 && now > _shouldLockAt + kAutoLockTimeoutLateMs)) { | ||||||
|  | 		_shouldLockAt = 0; | ||||||
|  | 		_autoLockTimer.cancel(); | ||||||
| 		Core::App().lockByPasscode(); | 		Core::App().lockByPasscode(); | ||||||
| 	} else { | 	} else { | ||||||
| 		_shouldLockAt = now + (shouldLockInMs - checkTimeMs); | 		_shouldLockAt = now + (shouldLockInMs - checkTimeMs); | ||||||
|  |  | ||||||
|  | @ -316,6 +316,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	void checkAutoLock(); | 	void checkAutoLock(); | ||||||
| 	void checkAutoLockIn(crl::time time); | 	void checkAutoLockIn(crl::time time); | ||||||
|  | 	void localPasscodeChanged(); | ||||||
| 
 | 
 | ||||||
| 	rpl::lifetime &lifetime() { | 	rpl::lifetime &lifetime() { | ||||||
| 		return _lifetime; | 		return _lifetime; | ||||||
|  |  | ||||||
|  | @ -452,10 +452,13 @@ void PasscodeBox::save(bool force) { | ||||||
| 			changeCloudPassword(old, pwd); | 			changeCloudPassword(old, pwd); | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
|  | 		const auto weak = make_weak(this); | ||||||
| 		cSetPasscodeBadTries(0); | 		cSetPasscodeBadTries(0); | ||||||
| 		Local::setPasscode(pwd.toUtf8()); | 		Local::setPasscode(pwd.toUtf8()); | ||||||
| 		Auth().checkAutoLock(); | 		Auth().localPasscodeChanged(); | ||||||
| 		closeBox(); | 		if (weak) { | ||||||
|  | 			closeBox(); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue