Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.0.0
-
None
-
fc5ddb181896d3a364c046ae21b61283412fc722
Description
There might be something strange with the current SignalSpy. I created this small test qml:
import QtQuick 1.0 import QtTest 1.0 TestCase { id: spyTest name: "SpyTest" SignalSpy { id: spy } function test_spy_data() { return [ {tag: "round 1"}, {tag: "round 2"} ] } function test_spy(data) { var obj = Qt.createQmlObject( "import QtQuick 1.0 \n" + "Item {\n" + " signal dummySignal\n" + " property alias timer: dummyTimer\n" + " Timer {\n" + " id: dummyTimer\n" + " interval: 200; repeat: true\n" + " onTriggered: {parent.dummySignal();console.log(\"dummyTimer signaled!\");}\n" + " }\n" + "}\n", spyTest); spy.target = obj; spy.signalName = "dummySignal"; spy.clear(); compare(spy.count, 0); obj.timer.start(); spyTest.wait(500); compare(spy.count, 2); obj.timer.stop(); } }
There is one signalspy, which is used for multiple test objects. When SignalSpy is used with the first object, it works fine. When it is used with the 2nd created object, it gives a warning (see below). Also the signal-counter after this is not working reliably anymore, even though the signal seems to be emitted.
This is the log I get:
********* Start testing of qmlexample ********* Config: Using QTest library 5.0.0, Qt 5.0.0 PASS : SpyTest::initTestCase() QDEBUG : SpyTest::test_spy(round 1) dummyTimer signaled! QDEBUG : SpyTest::test_spy(round 1) dummyTimer signaled! QWARN : SpyTest::test_spy(round 2) ---/imports/QtTest/SignalSpy.qml:95: Error: Function.prototype.disconnect: target is not a function QDEBUG : SpyTest::test_spy(round 2) dummyTimer signaled! QDEBUG : SpyTest::test_spy(round 2) dummyTimer signaled! FAIL! : SpyTest::test_spy(round 2) Compared values are not the same Actual (): 0 Expected (): 2
Is there something wrong with the testcode or is SignalSpy somehow broken?
Attachments
Issue Links
- relates to
-
QTBUG-47405 SignalSpy.count returns wrong value
- Closed