diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2024-10-17 14:49:12 +0200 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-10-21 17:53:52 +0000 |
| commit | 0f629cbbec2d59f98503174cbbe47354a8af5854 (patch) | |
| tree | 38835cab60ccee12727ab6b5d314c1dc8856bb55 | |
| parent | ed10a50c554b7b182a339482594d25c80a0f5cbe (diff) | |
QQmlProperty: Don't clear toplevel binding bit for value type bindings
If we remove a value type binding from a proxy binding, the proxy
binding is still there. We must not clear the toplevel binding bit then.
Amends commit c9d7620bc2e47d3e1b84f824eb5b643f269f4a56
Pick-to: 6.2
Fixes: QTBUG-130143
Change-Id: Ie4f1ba4a22a1e15eaa218fb8e72f78964ae8cf75
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit cdcfed60e12a0ba386287c8bdd96736c6a639b7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit e1cfc24d39b0e199f60e864c78dd7476f01d1cd1)
| -rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 12 | ||||
| -rw-r--r-- | tests/auto/qml/qqmllanguage/data/TextItem.qml | 7 | ||||
| -rw-r--r-- | tests/auto/qml/qqmllanguage/data/Wrap.qml | 6 | ||||
| -rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 8 |
4 files changed, 27 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index a4ba51cd73..1a9304830d 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -872,18 +872,18 @@ static void removeOldBinding(QObject *object, QQmlPropertyIndex index, QQmlPrope oldBinding = oldBinding->nextBinding(); } - if (valueTypeIndex != -1 - && oldBinding - && oldBinding->kind() == QQmlAbstractBinding::ValueTypeProxy) { - oldBinding = static_cast<QQmlValueTypeProxyBinding *>(oldBinding.data())->binding(index); - } - if (!oldBinding) { // Clear the binding bit so that the binding doesn't appear later for any reason data->clearBindingBit(coreIndex); return; } + if (valueTypeIndex != -1 && oldBinding->kind() == QQmlAbstractBinding::ValueTypeProxy) { + oldBinding = static_cast<QQmlValueTypeProxyBinding *>(oldBinding.data())->binding(index); + if (!oldBinding) + return; + } + if (!(flags & QQmlPropertyPrivate::DontEnable)) oldBinding->setEnabled(false, {}); oldBinding->removeFromObject(); diff --git a/tests/auto/qml/qqmllanguage/data/TextItem.qml b/tests/auto/qml/qqmllanguage/data/TextItem.qml new file mode 100644 index 0000000000..1f6f171b41 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/TextItem.qml @@ -0,0 +1,7 @@ +import QtQuick + +Text { + property bool testBool: false + font.family: "Ar" + "iallll" + onTestBoolChanged: font.pixelSize = 16; +} diff --git a/tests/auto/qml/qqmllanguage/data/Wrap.qml b/tests/auto/qml/qqmllanguage/data/Wrap.qml new file mode 100644 index 0000000000..365350f16e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/Wrap.qml @@ -0,0 +1,6 @@ +import QtQuick + +TextItem { + font.pixelSize: height * 0.9 + testBool: true +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 7992896506..806bb604e8 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -8262,6 +8262,14 @@ void tst_qqmllanguage::overrideInnerBinding() QCOMPARE(o->property("width").toReal(), 20.0); QCOMPARE(o->property("innerWidth").toReal(), 20.0); + + QQmlComponent c2(&e, testFileUrl("Wrap.qml")); + QVERIFY2(c2.isReady(), qPrintable(c2.errorString())); + o.reset(c2.create()); + QVERIFY(!o.isNull()); + + QFont font = qvariant_cast<QFont>(o->property("font")); + QCOMPARE(font.family(), "Ariallll"); } QTEST_MAIN(tst_qqmllanguage) |
