diff options
author | Arno Rehn <a.rehn@menlosystems.com> | 2019-02-04 11:51:52 +0100 |
---|---|---|
committer | Arno Rehn <a.rehn@menlosystems.com> | 2019-02-04 15:24:32 +0000 |
commit | d14c6aa5855ebfb8bb624efd7817bb3cdd4c96e4 (patch) | |
tree | 2984d8ce4625d1f66b3fbaf54086cc56f2d4128e /tests | |
parent | 38b5128c63ba38303f0587e03536ed546c1f2eca (diff) | |
download | qtwebchannel-d14c6aa5855ebfb8bb624efd7817bb3cdd4c96e4.tar.gz |
Also add already wrapped objects to the transport-to-objects map
Fixes a crash: Previously, when a connection was closed, the transport
was not removed from the list of transports of a wrapped objects. This
was because the transport was not added to the transport-to-object map
in the first place. When a property update was pushed, the now dangling
pointer to the "old" transport caused a crash.
Change-Id: Ib980f0b874851f8f85f7a3d76d51a2c884504b96
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/webchannel/tst_webchannel.cpp | 16 | ||||
-rw-r--r-- | tests/auto/webchannel/tst_webchannel.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp index e46d097..57aab53 100644 --- a/tests/auto/webchannel/tst_webchannel.cpp +++ b/tests/auto/webchannel/tst_webchannel.cpp @@ -799,6 +799,22 @@ void TestWebChannel::testWrapValues() } } +void TestWebChannel::testWrapObjectWithMultipleTransports() +{ + QWebChannel channel; + QMetaObjectPublisher *pub = channel.d_func()->publisher; + + DummyTransport *dummyTransport = new DummyTransport(this); + DummyTransport *dummyTransport2 = new DummyTransport(this); + + TestObject obj; + + pub->wrapResult(QVariant::fromValue(&obj), dummyTransport); + pub->wrapResult(QVariant::fromValue(&obj), dummyTransport2); + + QCOMPARE(pub->transportedWrappedObjects.count(), 2); +} + void TestWebChannel::testJsonToVariant() { QWebChannel channel; diff --git a/tests/auto/webchannel/tst_webchannel.h b/tests/auto/webchannel/tst_webchannel.h index 40e6fba..3d725f4 100644 --- a/tests/auto/webchannel/tst_webchannel.h +++ b/tests/auto/webchannel/tst_webchannel.h @@ -315,6 +315,7 @@ private slots: void testRemoveUnusedTransports(); void testPassWrappedObjectBack(); void testWrapValues(); + void testWrapObjectWithMultipleTransports(); void testJsonToVariant(); void testInfiniteRecursion(); void testAsyncObject(); |