plugins/nightlight: Guard against invalid timings in the config

Morning and evening timings should be ordered correctly. When computing
the daylight duration, that ternary operator should not be needed and it
hides other bugs.
wilder/Plasma/6.2
Vlad Zahorodnii 2 years ago
parent 07f266e7c7
commit 786b3ffbae
  1. 6
      src/plugins/nightlight/nightlightmanager.cpp

@ -279,8 +279,12 @@ void NightLightManager::readConfig()
// fixed timings
QTime mrB = QTime::fromString(s->morningBeginFixed(), "hhmm");
QTime evB = QTime::fromString(s->eveningBeginFixed(), "hhmm");
if (mrB >= evB) {
mrB = QTime(6, 0);
evB = QTime(18, 0);
}
int diffME = evB > mrB ? mrB.msecsTo(evB) : evB.msecsTo(mrB);
int diffME = mrB.msecsTo(evB);
int diffMin = std::min(diffME, MSC_DAY - diffME);
int trTime = s->transitionTime() * 1000 * 60;

Loading…
Cancel
Save