summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-05-19 11:49:37 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-06-19 23:22:33 +0000
commitb2be272d354defaebd82dfaa2dffefa5a8f3a303 (patch)
treec4b044e60b8c4ac975feefb8143bbefac47fbbb1 /src/corelib/kernel/qobject.cpp
parent54589f293297f0c132a7814a14f0d6ab38393b19 (diff)
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 'src/corelib/kernel/qobject.cpp')
-rw-r--r--src/corelib/kernel/qobject.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 1836405b9c..676a529dfe 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4913,6 +4913,16 @@ QMetaObject::Connection::~Connection()
static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
}
+/*! \internal Returns true if the object is still connected */
+bool QMetaObject::Connection::isConnected_helper() const
+{
+ Q_ASSERT(d_ptr); // we're only called from operator RestrictedBool() const
+ QObjectPrivate::Connection *c = static_cast<QObjectPrivate::Connection *>(d_ptr);
+
+ return c->receiver;
+}
+
+
/*!
\fn QMetaObject::Connection::operator bool() const