From 30e2e336a536786cf9a9de9736b0983df02fd041 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Wed, 16 Jul 2014 19:04:39 +0200 Subject: Properly disconnect a transport from the QtMetaObjectPublisher. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a bug, where messages from the transport would still be send to the QtMetaObjectPublisher even though it was previously disconnected. I'll refactor this code eventually to get rid of QtMetaObjectPublisher alltogether and merge its code into QWebChannelPrivate where appropriate. Change-Id: Ie0c35bd81a5e633bdcb6be55b64f947d4a545a59 Reviewed-by: Jocelyn Turcotte Reviewed-by: Lutz Schönemann --- tests/auto/webchannel/tst_webchannel.cpp | 8 ++++++++ tests/auto/webchannel/tst_webchannel.h | 6 ++++++ 2 files changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp index 900a6bb..2de34c9 100644 --- a/tests/auto/webchannel/tst_webchannel.cpp +++ b/tests/auto/webchannel/tst_webchannel.cpp @@ -244,6 +244,14 @@ void TestWebChannel::testInvokeMethodConversion() } } +void TestWebChannel::testDisconnect() +{ + QWebChannel channel; + channel.connectTo(m_dummyTransport); + channel.disconnectFrom(m_dummyTransport); + m_dummyTransport->emitMessageReceived(QJsonObject()); +} + static QHash createObjects(QObject *parent) { const int num = 100; diff --git a/tests/auto/webchannel/tst_webchannel.h b/tests/auto/webchannel/tst_webchannel.h index bd403dc..57e6b5d 100644 --- a/tests/auto/webchannel/tst_webchannel.h +++ b/tests/auto/webchannel/tst_webchannel.h @@ -56,6 +56,11 @@ public: {} ~DummyTransport() {}; + void emitMessageReceived(const QJsonObject &message) + { + emit messageReceived(message, this); + } + public slots: void sendMessage(const QJsonObject &/*message*/) Q_DECL_OVERRIDE { @@ -217,6 +222,7 @@ private slots: void testRegisterObjects(); void testInfoForObject(); void testInvokeMethodConversion(); + void testDisconnect(); void benchClassInfo(); void benchInitializeClients(); -- cgit v1.2.1