diff options
author | Knud Dollereder <knud.dollereder@qt.io> | 2022-08-02 13:25:08 +0200 |
---|---|---|
committer | Knud Dollereder <knud.dollereder@qt.io> | 2022-08-04 12:47:26 +0000 |
commit | 371d9ffe0fc7c2f68fc4b0c040d9989d44da1df3 (patch) | |
tree | ef058a2258737cdad25d71bc36805c5c82ad0d01 | |
parent | 184a9cbd64f852edc9e0b04e1859e17a597c5367 (diff) |
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: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Aleksei German <aleksei.german@qt.io>
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/propertyparser.cpp | 13 |
1 files changed, 5 insertions, 8 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 (tmp.canConvert(QMetaType::Double)) - value.convert(QMetaType::Double); - else if (tmp.canConvert(QMetaType::QColor)) - value.convert(QMetaType::QColor); + if (auto f = QVariant(str).toDouble(&conversionOk); conversionOk) + return f; + else if (auto c = colorFromString(str, &conversionOk); conversionOk) + return c; + break; } case QMetaType::QPoint: |