mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-03-27 01:03:09 +00:00
Preserve constructor dateAdded when JSON field is absent
This commit is contained in:
parent
9936374d4c
commit
03059af424
1 changed files with 6 additions and 1 deletions
|
|
@ -399,7 +399,12 @@ Game *Game::fromJson(const QJsonObject &json, QObject *parent)
|
||||||
game->setWorkingDirectory(workingDirectory);
|
game->setWorkingDirectory(workingDirectory);
|
||||||
game->setPlatform(platform);
|
game->setPlatform(platform);
|
||||||
game->setPlatformId(platformId);
|
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->setLastPlayed(QDateTime::fromString(json[QStringLiteral("lastPlayed")].toString(), Qt::ISODate));
|
||||||
game->setPlayTime(json[QStringLiteral("playTime")].toInteger());
|
game->setPlayTime(json[QStringLiteral("playTime")].toInteger());
|
||||||
game->setFavorite(json[QStringLiteral("favorite")].toBool());
|
game->setFavorite(json[QStringLiteral("favorite")].toBool());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue