diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-01-08 13:43:54 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-01-09 13:52:25 +0100 |
commit | 89c4bb5f2473b4616fdccbcc616eedfaa5d628cc (patch) | |
tree | 8642b5ed9250c4c3753fc5a45379dd1a95f878e0 /src | |
parent | bfbf8ca4536fda39a8fb34dbf149794437f68dff (diff) |
Deprecate QJsonDocument methods for converting to/from JSON binary
Also remove the example code for deprecated methods and use CBOR instead
where it makes sense.
Task-number: QTBUG-81068
Change-Id: Iffb7a4b3d7b16a1e485fc05b3ab2e2468e9e0718
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/serialization/qjsondocument.cpp | 7 | ||||
-rw-r--r-- | src/corelib/serialization/qjsondocument.h | 10 | ||||
-rw-r--r-- | src/gui/rhi/qshaderdescription.cpp | 10 |
3 files changed, 21 insertions, 6 deletions
diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index b9b1902f34..fe0500bdef 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -237,7 +237,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other) the application. */ -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! Creates a QJsonDocument that uses the first \a size bytes from \a data. It assumes \a data contains a binary encoded JSON document. @@ -385,10 +385,13 @@ QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidati QByteArray QJsonDocument::toBinaryData() const { int size = 0; +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED const char *raw = rawData(&size); +QT_WARNING_POP return QByteArray(raw, size); } -#endif // QT_CONFIG(binaryjson) +#endif // QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! Creates a QJsonDocument from the QVariant \a variant. diff --git a/src/corelib/serialization/qjsondocument.h b/src/corelib/serialization/qjsondocument.h index 325e47b531..758bbfd9dd 100644 --- a/src/corelib/serialization/qjsondocument.h +++ b/src/corelib/serialization/qjsondocument.h @@ -111,13 +111,19 @@ public: BypassValidation }; -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use CBOR format instead") static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate); + + QT_DEPRECATED_X("Use CBOR format instead") const char *rawData(int *size) const; + QT_DEPRECATED_X("Use CBOR format instead") static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate); + + QT_DEPRECATED_X("Use CBOR format instead") QByteArray toBinaryData() const; -#endif // QT_CONFIG(binaryjson) +#endif // QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) static QJsonDocument fromVariant(const QVariant &variant); QVariant toVariant() const; diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index d0f73f6aa7..7e9b7d7b8e 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -342,8 +342,11 @@ bool QShaderDescription::isValid() const */ QByteArray QShaderDescription::toBinaryJson() const { -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED return d->makeDoc().toBinaryData(); +QT_WARNING_POP #else qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature"); return QByteArray(); @@ -382,8 +385,11 @@ QByteArray QShaderDescription::toJson() const QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data) { QShaderDescription desc; -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data)); +QT_WARNING_POP #else Q_UNUSED(data); qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); |