diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-25 15:41:51 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-25 20:44:16 +0100 |
commit | 5bcbd0a513dcf929890a869ad01c68b3175fa6e2 (patch) | |
tree | 12e6ada4555ebe5a2469cacf3a58a7a2a1835a59 | |
parent | 43114c97559a0b0dfb101f87d43cf52782bd6f63 (diff) |
Binding: Accept local signal handlers again
Pick-to: 6.4 6.5
Fixes: QTBUG-110628
Change-Id: Ifc5023a3bfeb575df3102c3ea363903ebffa88ba
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | src/qml/types/qqmlbind.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qml/qqmlbinding/data/bindingWithHandler.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp | 12 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index b9ca7df7e6..a31e5ccd85 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -757,7 +757,8 @@ void QQmlBindPrivate::decodeBinding( if (!immediateState) return; - QQmlProperty property(q, propertyName); + QQmlProperty property = QQmlPropertyPrivate::create( + q, propertyName, contextData, QQmlPropertyPrivate::InitFlag::AllowSignal); if (property.isValid()) { if (!immediateState->hasCreator()) { immediateState->setCompletePending(true); diff --git a/tests/auto/qml/qqmlbinding/data/bindingWithHandler.qml b/tests/auto/qml/qqmlbinding/data/bindingWithHandler.qml new file mode 100644 index 0000000000..bd819167d8 --- /dev/null +++ b/tests/auto/qml/qqmlbinding/data/bindingWithHandler.qml @@ -0,0 +1,7 @@ +import QtQml + +Binding { + property string input + property string output + onInputChanged: output = input +} diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp index aa26fdc59d..c78763cf5f 100644 --- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp +++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp @@ -37,6 +37,7 @@ private slots: void bindNaNToInt(); void intOverflow(); void generalizedGroupedProperties(); + void localSignalHandler(); private: QQmlEngine engine; @@ -581,6 +582,17 @@ void tst_qqmlbinding::generalizedGroupedProperties() QCOMPARE(rootAttached->objectName(), QString()); } +void tst_qqmlbinding::localSignalHandler() +{ + QQmlEngine e; + QQmlComponent c(&e, testFileUrl("bindingWithHandler.qml")); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + o->setProperty("input", QStringLiteral("abc")); + QCOMPARE(o->property("output").toString(), QStringLiteral("abc")); +} + QTEST_MAIN(tst_qqmlbinding) #include "tst_qqmlbinding.moc" |