summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLutz Schönemann <lutz.schoenemann@basyskom.com>2014-12-01 16:12:22 +0100
committerSumedha Widyadharma <sumedha.widyadharma@basyskom.com>2014-12-03 10:47:44 +0100
commited40ffb381e1f874145b70de43961298428c03af (patch)
tree9d29e86e7664c25397e309f8196807c717063990 /tests
parent6a352361a54afa4b340e88771ff885ee32b932f2 (diff)
downloadqtwebchannel-ed40ffb381e1f874145b70de43961298428c03af.tar.gz
Fix crash on signal after deregistration
Implemented a remove method in SignalHandler that allows us to remove and disconnect an object from SignalHandler w/o decrementing the connection counter until it hits zero or deleting the object That same functionality was used to remove an object from internal lists when receiving a destroyed signal from an object. In case of deregistering an object we haven't received a destoryed signal but simulated reception of that signal and so that code was not called in that case. Change-Id: Ie20cf628a2de028375f5d29f913682e25ebf8d44 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp24
-rw-r--r--tests/auto/webchannel/tst_webchannel.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index 4827ea7..3304293 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -83,6 +83,30 @@ void TestWebChannel::testRegisterObjects()
channel.registerObjects(objects);
}
+void TestWebChannel::testDeregisterObjects()
+{
+ QWebChannel channel;
+ TestObject testObject;
+ testObject.setObjectName("myTestObject");
+
+
+ channel.registerObject(testObject.objectName(), &testObject);
+
+ channel.connectTo(m_dummyTransport);
+ channel.d_func()->publisher->initializeClients();
+
+ QJsonObject connectMessage =
+ QJsonDocument::fromJson(("{\"type\": 7,"
+ "\"object\": \"myTestObject\","
+ "\"signal\": " + QString::number(testObject.metaObject()->indexOfSignal("sig1()"))
+ + "}").toLatin1()).object();
+ channel.d_func()->publisher->handleMessage(connectMessage, m_dummyTransport);
+
+ emit testObject.sig1();
+ channel.deregisterObject(&testObject);
+ emit testObject.sig1();
+}
+
void TestWebChannel::testInfoForObject()
{
TestObject obj;
diff --git a/tests/auto/webchannel/tst_webchannel.h b/tests/auto/webchannel/tst_webchannel.h
index ad8c6a4..6564944 100644
--- a/tests/auto/webchannel/tst_webchannel.h
+++ b/tests/auto/webchannel/tst_webchannel.h
@@ -214,6 +214,7 @@ public:
private slots:
void testRegisterObjects();
+ void testDeregisterObjects();
void testInfoForObject();
void testInvokeMethodConversion();
void testDisconnect();