summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-06-11 11:33:24 -0700
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-06-24 23:11:36 +0000
commitb6d7b0ede59b52974baf53c805caecbb300ad90b (patch)
tree1ceda4d1d44677720b0bb0be10b34590e18dd165 /src/corelib/serialization
parent9eb78ce0faee6d5cba61d662c36e5c59876dc6cc (diff)
Fix conversion of QVariant() in QJsonArrays and Objects (through CBOR)
When I wrote the QCborValue to QJsonValue conversion, I used QJsonValue::Undefined because it allowed to keep some level of compatibility in CBOR, despite the function documentation saying that CBOR undefineds became JSON nulls. Which they did. But when we converted QJson{Array,Object} to be backed by CBOR classes, that Undefined meant the insertion into the array/object actually deleted the entry. [ChangeLog][JSON] Fixed a regression from 5.14 that caused values of default-constructed QVariants in QVariantLists, QVariantMaps and QVariantHashes to disappear when converting to JSON via fromVariant{,List,Map,Hash}. Fixes: QTBUG-84610 Change-Id: Ic0987177fe463f352db9bd84993f116e2bdacc75 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit cb1c66bd204c12d848f47de6411d31edbafaf008) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/serialization')
-rw-r--r--src/corelib/serialization/qjsoncbor.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp
index ee4dd90416..f7e885e287 100644
--- a/src/corelib/serialization/qjsoncbor.cpp
+++ b/src/corelib/serialization/qjsoncbor.cpp
@@ -281,11 +281,9 @@ QJsonValue qt_convertToJson(QCborContainerPrivate *d, qsizetype idx)
return qt_convertToJson(e.flags & Element::IsContainer ? e.container : nullptr, -e.type);
case QCborValue::Null:
- return QJsonValue();
-
case QCborValue::Undefined:
case QCborValue::Invalid:
- return QJsonValue::Undefined;
+ return QJsonValue();
case QCborValue::False:
return false;
@@ -376,6 +374,8 @@ QJsonValue QCborValue::toJsonValue() const
return true;
case Null:
+ case Undefined:
+ case Invalid:
return QJsonValue();
case Double:
@@ -384,10 +384,6 @@ QJsonValue QCborValue::toJsonValue() const
case SimpleType:
break;
- case Undefined:
- case Invalid:
- return QJsonValue::Undefined;
-
case ByteArray:
case String:
// empty strings