plugins/nightlight: Fix current time changing after updating transitions

When the slow update timer fires, it's going to pass m_next.first as the
current time in order to calculate the next transition timings. After
the timings have been calculated, the slow update timer will be started
with an interval of "todayNow.msecsTo(m_next.first)". Since todayNow
is a reference to m_next.first, the time diff will be 0, which will
throw off the night light manager. To fix that, make a copy of m_next.first
and then pass the copy as the current date time to resetSlowUpdateTimers().

BUG: 487901
This commit is contained in:
Vlad Zahorodnii 2024-06-07 22:02:54 +03:00
parent b2ff465490
commit 83502e29a9

View file

@ -375,7 +375,8 @@ void NightLightManager::resetSlowUpdateTimers(const QDateTime &todayNow)
m_slowUpdateStartTimer = std::make_unique<QTimer>();
m_slowUpdateStartTimer->setSingleShot(true);
connect(m_slowUpdateStartTimer.get(), &QTimer::timeout, this, [this]() {
resetSlowUpdateTimers(m_next.first);
const QDateTime nextMilestone = m_next.first; // make a copy so the current time stays the same after updateTransitionTimings() is called
resetSlowUpdateTimers(nextMilestone);
});
updateTransitionTimings(false, todayNow);
updateTargetTemperature();