aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-11-28 16:57:41 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-29 08:19:11 +0100
commit55b5e30901cd2616d729c61856dabe3bfda5e4f0 (patch)
treef98f90b01f4bc17e72bf0b515e78a7f2d970222e /tests/auto
parent612785f39e325b0578be89e09b0e32d7d08d471e (diff)
Fix JavaScript signal connect on alias without other handlers
The changed handlers for aliases are connected lazily in the engine. QQmlPropertyPrivate::flushSignal is responsible for that and called in other places, for example when installing a onSomeAliasPropertyChanged handler. However we were missing a call to flushSignal when doing onSomeAliasPropertyChanged.connect(...), i.e. using the JavaScript connect API. Task-number: QTBUG-30493 Change-Id: Ia3f008626fd7af3f2cfbdd30d13fb83158bed4d5 Reviewed-by: Albert Astals Cid <albert.astals@canonical.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalHandlers.qml34
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp7
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
index 975be1b2ad..7e85312692 100644
--- a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
@@ -57,4 +57,38 @@ QtObject {
if (onTestSignal !== undefined)
definedHandlerResult = true;
}
+
+ property QtObject objWithAlias: QtObject {
+ id: testObjectWithAlias
+
+ property int count: 0;
+ property alias countAlias: testObjectWithAlias.count
+ }
+
+ function testConnectionOnAlias() {
+ var called = false;
+
+ testObjectWithAlias.onCountAliasChanged.connect(function() {
+ called = true
+ })
+
+ testObjectWithAlias.count++;
+ return called;
+ }
+
+ property QtObject objWithAliasHandler: QtObject {
+ id: testObjectWithAliasHandler
+
+ property bool testSuccess: false
+
+ property int count: 0
+ property alias countAlias: testObjectWithAliasHandler.count
+ onCountAliasChanged: testSuccess = true
+ }
+
+ function testAliasSignalHandler() {
+ testObjectWithAliasHandler.testSuccess = false
+ testObjectWithAliasHandler.count++
+ return testObjectWithAliasHandler.testSuccess
+ }
}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 6b19c13109..660be13f71 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -6060,6 +6060,13 @@ void tst_qqmlecmascript::signalHandlers()
QMetaObject::invokeMethod(o, "testSignalHandlerDefined");
QCOMPARE(o->property("definedHandlerResult").toBool(), true);
+ QVariant result;
+ QMetaObject::invokeMethod(o, "testConnectionOnAlias", Q_RETURN_ARG(QVariant, result));
+ QCOMPARE(result.toBool(), true);
+
+ QMetaObject::invokeMethod(o, "testAliasSignalHandler", Q_RETURN_ARG(QVariant, result));
+ QCOMPARE(result.toBool(), true);
+
delete o;
}