From 03059af4240b1b5abc40c41af75b349e7a020d20 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Mon, 23 Mar 2026 13:03:59 +0100 Subject: [PATCH] Preserve constructor dateAdded when JSON field is absent --- src/game.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game.cpp b/src/game.cpp index cb3fa6e..794911d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -399,7 +399,12 @@ Game *Game::fromJson(const QJsonObject &json, QObject *parent) game->setWorkingDirectory(workingDirectory); game->setPlatform(platform); game->setPlatformId(platformId); - game->setDateAdded(QDateTime::fromString(json[QStringLiteral("dateAdded")].toString(), Qt::ISODate)); + { + const QDateTime dt = QDateTime::fromString(json[QStringLiteral("dateAdded")].toString(), Qt::ISODate); + if (dt.isValid()) { + game->setDateAdded(dt); + } + } game->setLastPlayed(QDateTime::fromString(json[QStringLiteral("lastPlayed")].toString(), Qt::ISODate)); game->setPlayTime(json[QStringLiteral("playTime")].toInteger()); game->setFavorite(json[QStringLiteral("favorite")].toBool());