diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-10-07 10:01:46 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-10-07 11:31:17 +0200 |
commit | 00f903f3b4cd46ddf8361876401e5405030f97f1 (patch) | |
tree | 8ba52e5e8e74557aa5313ddbc6f6fbcb444f1545 /tests/auto/qml/qqmlbinding/data | |
parent | dce305c4041a6ee65d486f3b31dc49c274ecdcbd (diff) |
QML Binding: do not convert strings
The root cause for the issue is that QQmlObjectCreator::setPropertyValue
calls QQmlStringConverters::variantFromString on strings if the property
is of type QVariant. Unfortunately, this cannot be changed easily as the
current behavior is explicitly documented and tested in tst_qqmllanguage,
thus making it a breaking change.
As a workaround, QML Binding does now take a QJSValue instead of a
QVariant (making value a var property), which does not trigger the
conversion path.
Fixes: QTBUG-78943
Change-Id: I0b64dffdb6b84b2bab2bb85a8cb263e530c18570
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlbinding/data')
-rw-r--r-- | tests/auto/qml/qqmlbinding/data/noUnexpectedStringConversion.qml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlbinding/data/noUnexpectedStringConversion.qml b/tests/auto/qml/qqmlbinding/data/noUnexpectedStringConversion.qml new file mode 100644 index 0000000000..d0f30c5da5 --- /dev/null +++ b/tests/auto/qml/qqmlbinding/data/noUnexpectedStringConversion.qml @@ -0,0 +1,30 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Window { +visible: true +width: 640 +height: 480 +title: qsTr("Hello World") + + Rectangle { + id: colorRect + objectName: "colorRect" + anchors.fill: parent + Text { + objectName: "colorLabel" + id: colorLabel + } + } + + Binding { + target: colorLabel + property: "text" + value: "red" + } + Binding { + target: colorRect + property: "color" + value: "red" + } +} |