diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-25 15:41:51 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-01-26 08:30:40 +0000 |
commit | e31a4def53e92e2f89a364e3ebec58deacd98d5c (patch) | |
tree | bf63db4412d9eb70f4b9a0ae4789d2292c941fdd | |
parent | 3518b86277bc51fe8325b803c3769c6988dc05c4 (diff) |
Binding: Accept local signal handlers again
Fixes: QTBUG-110628
Change-Id: Ifc5023a3bfeb575df3102c3ea363903ebffa88ba
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 5bcbd0a513dcf929890a869ad01c68b3175fa6e2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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 5726d4a560..34f288b9d5 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->creator) { immediateState->completePending = 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 faa64ddac5..9c0caf1aee 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; @@ -572,6 +573,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" |