summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qjsoncbor.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-06-11 11:33:24 -0700
committerUlf Hermann <ulf.hermann@qt.io>2020-06-24 22:43:57 +0200
commitcb1c66bd204c12d848f47de6411d31edbafaf008 (patch)
treebc0c10d5f5e1970fcf181a05f839d6c07136998c /src/corelib/serialization/qjsoncbor.cpp
parentbdc2493096d3eab932da0cdf50b4c7238bf333b3 (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 Pick-to: 5.15 Change-Id: Ic0987177fe463f352db9bd84993f116e2bdacc75 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qjsoncbor.cpp')
-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 000008db50..8bb04fa3bf 100644
--- a/src/corelib/serialization/qjsoncbor.cpp
+++ b/src/corelib/serialization/qjsoncbor.cpp
@@ -280,11 +280,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;
@@ -375,6 +373,8 @@ QJsonValue QCborValue::toJsonValue() const
return true;
case Null:
+ case Undefined:
+ case Invalid:
return QJsonValue();
case Double:
@@ -383,10 +383,6 @@ QJsonValue QCborValue::toJsonValue() const
case SimpleType:
break;
- case Undefined:
- case Invalid:
- return QJsonValue::Undefined;
-
case ByteArray:
case String:
// empty strings