diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2014-08-11 13:43:38 +0200 |
---|---|---|
committer | Ismo Haataja <ismo.haataja@digia.com> | 2014-08-26 08:12:44 +0200 |
commit | 5d204b2879c8eb1cd98e7713db8a26905fbc6cfd (patch) | |
tree | 5e153384c9298d4b1d44fceccd623cf422895003 | |
parent | dac411122a9275eac6b94c1cd3ca0c300937cf83 (diff) | |
download | qtwebchannel-5d204b2879c8eb1cd98e7713db8a26905fbc6cfd.tar.gz |
Get rid of setTimeout calls in qwebchannel.js client code.
This was a historic artefact which should not be required anymore.
Back then it was added when trying to improve the perceived performance
of the webchannel on an embedded device. Nowadays, using the built-in
WebKit IPC mechanism instead of WebSockets, paired with the rest of
the code cleanup and other changes, it should not be required anymore.
Change-Id: I4b2d76d84aaf92e12592a0b2bcf94710b697846e
Reviewed-by: Lutz Schönemann <lutz.schoenemann@basyskom.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/webchannel/qwebchannel.js | 4 | ||||
-rw-r--r-- | tests/auto/qml/Client.qml | 25 | ||||
-rw-r--r-- | tests/auto/qml/tst_webchannel.qml | 6 |
3 files changed, 8 insertions, 27 deletions
diff --git a/src/webchannel/qwebchannel.js b/src/webchannel/qwebchannel.js index 2df8704..4b031c0 100644 --- a/src/webchannel/qwebchannel.js +++ b/src/webchannel/qwebchannel.js @@ -154,7 +154,7 @@ var QWebChannel = function(transport, initCallback) console.warn("Unhandled property update: " + data.object + "::" + data.signal); } } - setTimeout(function() { channel.exec({type: QWebChannelMessageTypes.idle}); }, 0); + channel.exec({type: QWebChannelMessageTypes.idle}); } // prevent multiple initialization which might happen with multiple webchannel clients. @@ -172,7 +172,7 @@ var QWebChannel = function(transport, initCallback) if (initCallback) { initCallback(channel); } - setTimeout(function() { channel.exec({type: QWebChannelMessageTypes.idle}); }, 0); + channel.exec({type: QWebChannelMessageTypes.idle}); } this.debug = function(message) diff --git a/tests/auto/qml/Client.qml b/tests/auto/qml/Client.qml index 0b623a0..161a85e 100644 --- a/tests/auto/qml/Client.qml +++ b/tests/auto/qml/Client.qml @@ -86,30 +86,6 @@ Item { } readonly property var clientTransport: clientTransport - Timer { - id: timer - running: false - repeat: false - - property var callback - - onTriggered: { - callback(); - } - } - - function setTimeout(callback, delay) - { - if (timer.running) { - console.error("nested calls to setTimeout are not supported!", JSON.stringify(callback), JSON.stringify(timer.callback)); - return; - } - timer.callback = callback; - // note: an interval of 0 is directly triggered, so add a little padding - timer.interval = delay + 1; - timer.running = true; - } - function createChannel(callback, raw) { return new JSClient.QWebChannel(clientTransport, callback, raw); @@ -118,7 +94,6 @@ Item { function cleanup() { clientMessages = []; - timer.running = false; } function awaitRawMessage() diff --git a/tests/auto/qml/tst_webchannel.qml b/tests/auto/qml/tst_webchannel.qml index 46ac209..899db69 100644 --- a/tests/auto/qml/tst_webchannel.qml +++ b/tests/auto/qml/tst_webchannel.qml @@ -256,6 +256,8 @@ TestCase { compare(msg.args, ["foobar"]); compare(lastMethodArg, "foobar"); + client.awaitIdle(); + myFactory.lastObj.mySignal("foobar", 42); // deleteLater call @@ -292,8 +294,12 @@ TestCase { compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); compare(typeof channel.objects[testObjId], "object"); + client.awaitIdle(); + channel.objects[testObjId].deleteLater(); msg = client.awaitMessage(); + compare(msg.type, JSClient.QWebChannelMessageTypes.invokeMethod); + compare(msg.object, testObjId); // after receiving the destroyed signal the client deletes // local objects and sends back a idle message |