diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-05-19 11:49:37 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-06-19 23:22:33 +0000 |
commit | b2be272d354defaebd82dfaa2dffefa5a8f3a303 (patch) | |
tree | c4b044e60b8c4ac975feefb8143bbefac47fbbb1 /tests/auto/corelib/kernel | |
parent | 54589f293297f0c132a7814a14f0d6ab38393b19 (diff) | |
download | qtbase-b2be272d354defaebd82dfaa2dffefa5a8f3a303.tar.gz |
Make QMetaObject::Connection check its state deeply
Since Connection can be copied, one copy could be used for
disconnecting, but the other's d_ptr wouldn't get updated and would
continue to report as still connected.
This patch fixes that by making it check the internal state. That is
only done after d_ptr is already known to be non-null. Unfortunately,
that is the common path:
if (connect(sender, &Sender::signal, [] {}))
will call an out-of-line function. I don't see a way out.
Task-number: QTBUG-46213
Change-Id: I66a35ce5f88941f29aa6ffff13dfb45dca68a350
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r-- | tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 3ec84b5198..4617ce5e74 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -918,6 +918,8 @@ void tst_QObject::connectDisconnectNotifyPMF() QMetaObject::Connection conn = connect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1); + QVERIFY(conn); + // Test disconnectNotify when disconnecting by QMetaObject::Connection QVERIFY(QObject::disconnect(conn)); // disconnectNotify() is not called, but it probably should be. @@ -5751,7 +5753,6 @@ void tst_QObject::connectFunctorWithContext() { int status = 1; SenderObject obj; - QMetaObject::Connection handle; ContextObject *context = new ContextObject; QEventLoop e; @@ -6058,8 +6059,12 @@ void tst_QObject::disconnectDoesNotLeakFunctor() QVERIFY(c2); QCOMPARE(countedStructObjectsCount, 2); QVERIFY(QObject::disconnect(c1)); + QVERIFY(!c1); + QVERIFY(!c2); // functor object has been destroyed QCOMPARE(countedStructObjectsCount, 1); + QVERIFY(!QObject::disconnect(c2)); + QCOMPARE(countedStructObjectsCount, 1); } QCOMPARE(countedStructObjectsCount, 0); } |