Add more assertions in online update.

This commit is contained in:
John Preston 2019-06-17 14:19:19 +02:00
parent d9e93fb5cc
commit 90ecec1d2e
1 changed files with 3 additions and 0 deletions

View File

@ -3535,6 +3535,7 @@ void MainWidget::updateOnline(bool gotOtherOffline) {
bool isOnline = !App::quitting() && App::wnd()->isActive();
int updateIn = Global::OnlineUpdatePeriod();
Assert(updateIn >= 0);
if (isOnline) {
const auto idle = crl::now() - Core::App().lastNonIdleTime();
if (idle >= Global::OfflineIdleTimeout()) {
@ -3545,6 +3546,7 @@ void MainWidget::updateOnline(bool gotOtherOffline) {
}
} else {
updateIn = qMin(updateIn, int(Global::OfflineIdleTimeout() - idle));
Assert(updateIn >= 0);
}
}
auto ms = crl::now();
@ -3579,6 +3581,7 @@ void MainWidget::updateOnline(bool gotOtherOffline) {
_lastSetOnline = ms;
} else if (isOnline) {
updateIn = qMin(updateIn, int(_lastSetOnline + Global::OnlineUpdatePeriod() - ms));
Assert(updateIn >= 0);
}
_onlineTimer.callOnce(updateIn);
}