diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-06-05 07:42:33 +0200 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-06-05 07:42:33 +0200 |
commit | db8b9569f83ba3643c9005359ba556f2c3e357f4 (patch) | |
tree | dd3f65ba8007b6f08e776880995cfbba00ba63ff /lib/syncdata.cpp | |
parent | 79ede9bcb6d4fc5e269f506b2a10bfe4c302040a (diff) | |
download | libquotient-db8b9569f83ba3643c9005359ba556f2c3e357f4.tar.gz libquotient-db8b9569f83ba3643c9005359ba556f2c3e357f4.zip |
Use CBOR for binary JSON caching on Qt 5.15+
Qt 5.15 deprecates binary JSON format in favour of CBOR now used as
a backend for its JSON classes.
Diffstat (limited to 'lib/syncdata.cpp')
-rw-r--r-- | lib/syncdata.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp index 6e68e2cd..a9ec5ee7 100644 --- a/lib/syncdata.cpp +++ b/lib/syncdata.cpp @@ -157,10 +157,14 @@ QJsonObject SyncData::loadJson(const QString& fileName) } auto data = roomFile.readAll(); - const auto json = (data.startsWith('{') - ? QJsonDocument::fromJson(data) - : QJsonDocument::fromBinaryData(data)) - .object(); + const auto json = data.startsWith('{') + ? QJsonDocument::fromJson(data).object() +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + : QCborValue::fromCbor(data).toJsonValue().toObject() +#else + : QJsonDocument::fromBinaryData(data).object() +#endif + ; if (json.isEmpty()) { qCWarning(MAIN) << "State cache in" << fileName << "is broken or empty, discarding"; |