Preserve constructor dateAdded when JSON field is absent

This commit is contained in:
Marco Allegretti 2026-03-23 13:03:59 +01:00
parent 9936374d4c
commit 03059af424

View file

@ -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());