diff options
-rw-r--r-- | src/qml/types/qqmlconnections.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmlconnections/data/disabled-at-start.qml | 14 | ||||
-rw-r--r-- | tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp | 18 |
3 files changed, 33 insertions, 0 deletions
diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp index cbf0f69093..7607c19374 100644 --- a/src/qml/types/qqmlconnections.cpp +++ b/src/qml/types/qqmlconnections.cpp @@ -287,6 +287,7 @@ void QQmlConnections::connectSignals() int signalIndex = QQmlPropertyPrivate::get(prop)->signalIndex(); QQmlBoundSignal *signal = new QQmlBoundSignal(target, signalIndex, this, qmlEngine(this)); + signal->setEnabled(d->enabled); QQmlBoundSignalExpression *expression = ctxtdata ? new QQmlBoundSignalExpression(target, signalIndex, diff --git a/tests/auto/qml/qqmlconnections/data/disabled-at-start.qml b/tests/auto/qml/qqmlconnections/data/disabled-at-start.qml new file mode 100644 index 0000000000..1a823f87f6 --- /dev/null +++ b/tests/auto/qml/qqmlconnections/data/disabled-at-start.qml @@ -0,0 +1,14 @@ +import QtQuick 2.9 + +Item { + id: root + + property bool tested: false + signal testMe() + + Connections { + target: root + enabled: false + onTestMe: root.tested = true; + } +} diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index b3ac1ce958..fe45495f74 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -52,6 +52,7 @@ private slots: void rewriteErrors(); void singletonTypeTarget(); void enableDisable_QTBUG_36350(); + void disabledAtStart(); void clearImplicitTarget(); private: @@ -353,6 +354,23 @@ void tst_qqmlconnections::enableDisable_QTBUG_36350() delete item; } +void tst_qqmlconnections::disabledAtStart() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("disabled-at-start.qml")); + QObject * const object = c.create(); + + QVERIFY(object != 0); + + QCOMPARE(object->property("tested").toBool(), false); + const int index = object->metaObject()->indexOfSignal("testMe()"); + const QMetaMethod method = object->metaObject()->method(index); + method.invoke(object, Qt::DirectConnection); + QCOMPARE(object->property("tested").toBool(), false); + + delete object; +} + //QTBUG-56499 void tst_qqmlconnections::clearImplicitTarget() { |