From 371d9ffe0fc7c2f68fc4b0c040d9989d44da1df3 Mon Sep 17 00:00:00 2001 From: Knud Dollereder Date: Tue, 2 Aug 2022 13:25:08 +0200 Subject: [PATCH] Fix a wrong property conversion QVariant::canConvert returns just the general ability to convert from one type to the other and does not reflect if the specific string inside the variant can be converted. For this reason tmp.canConvert(QMetaType::Double) returned always true which lead to colors inside keyframes becoming black as soon as the scene was saved. Fixes: QDS-6960 Change-Id: I1a267d93a7cffb080ae884df490e5723592a2780 Reviewed-by: Reviewed-by: Aleksei German --- .../qmldesigner/designercore/model/propertyparser.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/model/propertyparser.cpp b/src/plugins/qmldesigner/designercore/model/propertyparser.cpp index eab05e0adc4..21fcc0fa566 100644 --- a/src/plugins/qmldesigner/designercore/model/propertyparser.cpp +++ b/src/plugins/qmldesigner/designercore/model/propertyparser.cpp @@ -249,14 +249,11 @@ QVariant read(int variantType, const QString &str) if (str == "false") return false; - auto tmp = QVariant(str); - conversionOk = tmp.isValid(); - value = QVariant(tmp); + if (auto f = QVariant(str).toDouble(&conversionOk); conversionOk) + return f; + else if (auto c = colorFromString(str, &conversionOk); conversionOk) + return c; - if (tmp.canConvert(QMetaType::Double)) - value.convert(QMetaType::Double); - else if (tmp.canConvert(QMetaType::QColor)) - value.convert(QMetaType::QColor); break; } case QMetaType::QPoint: