aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp33
-rw-r--r--tests/auto/webchannel/tst_webchannel.h3
2 files changed, 35 insertions, 1 deletions
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index 6764204..13d1567 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -1080,6 +1080,39 @@ void TestWebChannel::qtbug46548_overriddenProperties()
#endif // WEBCHANNEL_TESTS_CAN_USE_JS_ENGINE
}
+void TestWebChannel::qtbug62388_wrapObjectMultipleTransports()
+{
+ QWebChannel channel;
+ TestObject obj;
+
+ auto initTransport = [&channel](QWebChannelAbstractTransport *transport) {
+ channel.connectTo(transport);
+ channel.d_func()->publisher->initializeClient(transport);
+ };
+ initTransport(m_dummyTransport);
+
+ auto queryObjectInfo = [&channel](QObject *obj, QWebChannelAbstractTransport *transport) {
+ return channel.d_func()->publisher->wrapResult(QVariant::fromValue(obj), transport).toObject();
+ };
+ const auto objectInfo = queryObjectInfo(&obj, m_dummyTransport);
+
+ QCOMPARE(objectInfo.length(), 3);
+ QVERIFY(objectInfo.contains("id"));
+ QVERIFY(objectInfo.contains("__QObject*__"));
+ QVERIFY(objectInfo.contains("data"));
+ QVERIFY(objectInfo.value("__QObject*__").isBool() && objectInfo.value("__QObject*__").toBool());
+
+ const auto id = objectInfo.value("id").toString();
+
+ QCOMPARE(channel.d_func()->publisher->unwrapObject(id), &obj);
+
+ DummyTransport transport;
+ initTransport(&transport);
+ QCOMPARE(queryObjectInfo(&obj, &transport), objectInfo);
+
+ // don't crash when the transport is destroyed
+}
+
QTEST_MAIN(TestWebChannel)
#include "tst_webchannel.moc"
diff --git a/tests/auto/webchannel/tst_webchannel.h b/tests/auto/webchannel/tst_webchannel.h
index 386f314..c4fee23 100644
--- a/tests/auto/webchannel/tst_webchannel.h
+++ b/tests/auto/webchannel/tst_webchannel.h
@@ -45,7 +45,7 @@ class DummyTransport : public QWebChannelAbstractTransport
{
Q_OBJECT
public:
- explicit DummyTransport(QObject *parent)
+ explicit DummyTransport(QObject *parent = nullptr)
: QWebChannelAbstractTransport(parent)
{}
~DummyTransport() {};
@@ -327,6 +327,7 @@ private slots:
void benchRemoveTransport();
void qtbug46548_overriddenProperties();
+ void qtbug62388_wrapObjectMultipleTransports();
private:
DummyTransport *m_dummyTransport;