From 37590c8ffe4810254f0172b1134466de3486570a Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 16 Mar 2026 00:30:32 +0200 Subject: [PATCH] fix updater infinitly checking if there is an update Signed-off-by: Trial97 --- launcher/updater/PrismExternalUpdater.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/launcher/updater/PrismExternalUpdater.cpp b/launcher/updater/PrismExternalUpdater.cpp index 72ca04ce2..3f9b91d5e 100644 --- a/launcher/updater/PrismExternalUpdater.cpp +++ b/launcher/updater/PrismExternalUpdater.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "StringUtils.h" @@ -268,20 +269,24 @@ void PrismExternalUpdater::setBetaAllowed(bool allowed) void PrismExternalUpdater::resetAutoCheckTimer() { if (priv->autoCheck && priv->updateInterval > 0) { - int timeoutDuration = 0; auto now = QDateTime::currentDateTime(); + + qint64 timeoutMs = 0; + if (priv->lastCheck.isValid()) { - auto diff = priv->lastCheck.secsTo(now); - auto secs_left = priv->updateInterval - diff; - if (secs_left < 0) - secs_left = 0; - timeoutDuration = secs_left * 1000; // to msec + qint64 diff = priv->lastCheck.secsTo(now); + qint64 secs_left = std::max(priv->updateInterval - diff, 0); + timeoutMs = secs_left * 1000; } - qDebug() << "Auto update timer starting," << timeoutDuration / 1000 << "seconds left"; - priv->updateTimer.start(timeoutDuration); + + timeoutMs = std::min(timeoutMs, static_cast(INT_MAX)); + + qDebug() << "Auto update timer starting," << timeoutMs / 1000 << "seconds left"; + priv->updateTimer.start(static_cast(timeoutMs)); } else { - if (priv->updateTimer.isActive()) + if (priv->updateTimer.isActive()) { priv->updateTimer.stop(); + } } }