diff --git a/src/lib/history/historymodel.cpp b/src/lib/history/historymodel.cpp index 9c15b50d7..aff160bd5 100644 --- a/src/lib/history/historymodel.cpp +++ b/src/lib/history/historymodel.cpp @@ -446,15 +446,18 @@ void HistoryModel::init() { QSqlQuery query; query.exec("SELECT MIN(date) FROM history"); - if (query.size() <= 0) { + if (!query.next()) { + return; + } + + const qint64 &minTimestamp = query.value(0).toLongLong(); + if (minTimestamp <= 0) { return; } const QDate &today = QDate::currentDate(); const QDate &week = today.addDays(1 - today.dayOfWeek()); const QDate &month = QDate(today.year(), today.month(), 1); - - const qint64 &minTimestamp = query.value(0).toLongLong(); const qint64 ¤tTimestamp = QDateTime::currentMSecsSinceEpoch(); qint64 timestamp = currentTimestamp;