diff options
-rw-r--r-- | src/webchannel/qwebchannel.js | 3 | ||||
-rw-r--r-- | tests/auto/qml/tst_webchannel.qml | 32 |
2 files changed, 12 insertions, 23 deletions
diff --git a/src/webchannel/qwebchannel.js b/src/webchannel/qwebchannel.js index 3feb829..d2c6525 100644 --- a/src/webchannel/qwebchannel.js +++ b/src/webchannel/qwebchannel.js @@ -236,8 +236,9 @@ function QObject(name, data, webChannel) object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || []; object.__objectSignals__[signalIndex].push(callback); - if (!isPropertyNotifySignal) { + if (!isPropertyNotifySignal && signalName !== "destroyed") { // only required for "pure" signals, handled separately for properties in propertyUpdate + // also note that we always get notified about the destroyed signal webChannel.exec({ type: QWebChannelMessageTypes.connectToSignal, object: object.__id__, diff --git a/tests/auto/qml/tst_webchannel.qml b/tests/auto/qml/tst_webchannel.qml index 3e76d12..f304197 100644 --- a/tests/auto/qml/tst_webchannel.qml +++ b/tests/auto/qml/tst_webchannel.qml @@ -244,11 +244,6 @@ TestCase { compare(myFactory.lastObj.objectName, "testObj"); compare(channel.objects[testObjId].objectName, "testObj"); - // deleteLater signal connection - msg = client.awaitMessage(); - compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); - compare(msg.object, testObjId); - // mySignal connection msg = client.awaitMessage(); compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); @@ -287,26 +282,23 @@ TestCase { // objects even if no callback function is set function test_wrapper_wrapEveryQObject() { + var testObj; var channel = client.createChannel(function(channel) { - channel.objects.myFactory.create("testObj"); + channel.objects.myFactory.create("testObj", function(obj) { + testObj = obj; + }); }); client.awaitInit(); // ignore first message (call to myFactory.create()) client.awaitMessage(); - - // second message connects to destroyed signal and contains the new objects ID - var msg = client.awaitMessage(); - verify(msg.object); - - var testObjId = msg.object; - compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); - compare(typeof channel.objects[testObjId], "object"); - client.awaitIdle(); - channel.objects[testObjId].deleteLater(); - msg = client.awaitMessage(); + verify(testObj); + var testObjId = testObj.__id__; + + testObj.deleteLater(); + var msg = client.awaitMessage(); compare(msg.type, JSClient.QWebChannelMessageTypes.invokeMethod); compare(msg.object, testObjId); @@ -329,14 +321,10 @@ TestCase { }); client.awaitInit(); - // first message (call to myFactory.create()) + // call to myFactory.create() var msg = client.awaitMessage(); compare(msg.type, JSClient.QWebChannelMessageTypes.invokeMethod); - // second message connects to destroyed signal - msg = client.awaitMessage(); - compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); - client.awaitIdle(); testObj.myProperty = 42; |