summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-07-12 17:44:49 +0200
committerThiago Macieira <thiago.macieira@intel.com>2017-03-17 05:40:32 +0000
commit1cf75af3f2f3430bab11f9ef1eea5deb4c59aa2e (patch)
treec02eff8c864f6cb48fcd73985f8323bb57ebf069 /tests
parentcd9b79e0e4b8d36ee7287c787cb57a6f0e1b5672 (diff)
Call disconnectNotify() when disconnecting a QMetaObject::Connection
In all other forms of disconnecting this is done. We also know the signal index, so there is no reason not to do this. Change-Id: Ic8b042cd8f45dbff74b42ee30c384a84bef78b20 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> (cherry picked from commit 972580accdd0732b33947e8b1ca0ba8943041bdc) Task-number: QTBUG-59500 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 4417aa2353..427a73f316 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -71,6 +71,7 @@ private slots:
void connectDisconnectNotify();
void connectDisconnectNotifyPMF();
void disconnectNotify_receiverDestroyed();
+ void disconnectNotify_metaObjConnection();
void connectNotify_connectSlotsByName();
void connectDisconnectNotify_shadowing();
void emitInDefinedOrder();
@@ -926,8 +927,7 @@ void tst_QObject::connectDisconnectNotifyPMF()
// Test disconnectNotify when disconnecting by QMetaObject::Connection
QVERIFY(QObject::disconnect(conn));
- // disconnectNotify() is not called, but it probably should be.
- QVERIFY(s->disconnectedSignals.isEmpty());
+ QVERIFY(!s->disconnectedSignals.isEmpty());
// Test connectNotify when connecting by function pointer
s->clearNotifications();
@@ -972,6 +972,25 @@ void tst_QObject::disconnectNotify_receiverDestroyed()
delete s;
}
+void tst_QObject::disconnectNotify_metaObjConnection()
+{
+ NotifyObject *s = new NotifyObject;
+ NotifyObject *r = new NotifyObject;
+
+ QMetaObject::Connection c = QObject::connect((SenderObject*)s, SIGNAL(signal1()),
+ (ReceiverObject*)r, SLOT(slot1()));
+ QVERIFY(c);
+ QVERIFY(QObject::disconnect(c));
+
+ QCOMPARE(s->disconnectedSignals.count(), 1);
+ QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1));
+
+ delete r;
+ QCOMPARE(s->disconnectedSignals.count(), 1);
+
+ delete s;
+}
+
class ConnectByNameNotifySenderObject : public QObject
{
Q_OBJECT