Commit dbedced6 authored by Volker Krause's avatar Volker Krause
Browse files

Don't search for the next opening time arbitrarily into the future

This can otherwise spin indefinitely on certain opening hours expressions,
at least once an evaluation bug for those in KOpeningHours is fixed.

Instead we now search one year forward at most, which is more than enough
for what we do here.
parent 66f4d648
Pipeline #282659 skipped
......@@ -17,7 +17,11 @@
using namespace KOSMIndoorMap;
OpeningHoursCache::OpeningHoursCache() = default;
OpeningHoursCache::OpeningHoursCache()
{
setTimeRange({}, {});
}
OpeningHoursCache::~OpeningHoursCache() = default;
void OpeningHoursCache::setMapData(const MapData &mapData)
......@@ -31,12 +35,15 @@ void OpeningHoursCache::setMapData(const MapData &mapData)
void OpeningHoursCache::setTimeRange(const QDateTime &begin, const QDateTime &end)
{
if (begin == m_begin && end == m_end) {
const auto actualBegin = begin.isValid() ? begin : QDateTime::currentDateTime();
const auto actualEnd = (end.isValid() && end > m_begin) ? end : actualBegin.addYears(1);
if (actualBegin == m_begin && actualEnd == m_end) {
return;
}
m_begin = begin.isValid() ? begin : QDateTime::currentDateTime();
m_end = (end > m_begin) ? end : QDateTime();
m_begin = actualBegin;
m_end = actualEnd;
m_cacheEntries.clear();
}
......
......@@ -38,7 +38,7 @@ private:
};
std::vector<Entry> m_cacheEntries;
QDateTime m_begin = QDateTime::currentDateTime();
QDateTime m_begin;
QDateTime m_end;
MapData m_mapData;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment