2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Fix possible crash in timer timeout values.

This commit is contained in:
John Preston
2017-12-08 18:15:00 +04:00
parent aef88559e8
commit 90f5f7dded
2 changed files with 13 additions and 12 deletions

View File

@@ -257,11 +257,11 @@ namespace {
int32 onlineWillChangeIn(TimeId online, TimeId now) {
if (online <= 0) {
if (-online > now) return -online - now;
if (-online > now) return std::max(-online - now, 86400);
return 86400;
}
if (online > now) {
return online - now;
return std::max(online - now, 86400);
}
int32 minutes = (now - online) / 60;
if (minutes < 60) {
@@ -272,7 +272,7 @@ namespace {
return (hours + 1) * 3600 - (now - online);
}
QDateTime dNow(date(now)), dTomorrow(dNow.date().addDays(1));
return dNow.secsTo(dTomorrow);
return std::max(dNow.secsTo(dTomorrow), 86400LL);
}
QString onlineText(UserData *user, TimeId now, bool precise) {