From c3d04642e172c024ff7af15830a8bc9d66223eb7 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 29 Apr 2022 14:23:09 +0200 Subject: [PATCH] QmlDesigner: Properly parse variant type If a property actually is a variant we have to properly parse the string and convert it to the correct type. Booleans and numbers were not probably converted. This did not create many issues, since the conversion happened later, but it broke copy and paste and merging. In Qt 5 this conversion seemed to happen mostly automatically. Boolean literals have to be handled explcitly, since e.g. "10" is technically true and can be interpreted as boolean. Task-numbner: QDS-5944 Change-Id: I35c7cae7041667c7eac81e36a285a394263b35a4 Reviewed-by: Vikas Pachdha --- .../designercore/model/propertyparser.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/designercore/model/propertyparser.cpp b/src/plugins/qmldesigner/designercore/model/propertyparser.cpp index 3c7b498a929..eab05e0adc4 100644 --- a/src/plugins/qmldesigner/designercore/model/propertyparser.cpp +++ b/src/plugins/qmldesigner/designercore/model/propertyparser.cpp @@ -242,9 +242,21 @@ QVariant read(int variantType, const QString &str) bool conversionOk = true; switch (variantType) { case QMetaType::QVariant: { + + if (str == "true") + return true; + + if (str == "false") + return false; + auto tmp = QVariant(str); - value = QVariant(tmp); conversionOk = tmp.isValid(); + value = QVariant(tmp); + + if (tmp.canConvert(QMetaType::Double)) + value.convert(QMetaType::Double); + else if (tmp.canConvert(QMetaType::QColor)) + value.convert(QMetaType::QColor); break; } case QMetaType::QPoint: