summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAxel Waggershauser <awagger@gmail.com>2013-03-06 17:18:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-07 08:37:26 +0100
commit6b68be9587c6d6946faff34f88d80de53f11ed86 (patch)
treefdee479ee1136782b86322ef31edb147549cf47d /src/corelib
parent079e3b4f3ee3ebe225539b5a896fec1e38804e11 (diff)
Let QMetaObject::connectSlotsByName(o) also check for signals of o
QMetaObject::connectSlotsByName(QObject* o) creates a list of all children to look for signals that match slots of o. This changeset simply adds the object o itself to that list. The motivation is to finally fix the long standing QtCreator bug QTCREATORBUG-6494. Where executing 'Go to slot...' and choosing 'accepted()' for a simple QDialog named 'MyDialog' will add a on_MyDialog_accepted() slot to MyDialog. That slot never gets connected. More details may be found in the linked QTBUG-7595. Task-number: QTBUG-7595 Task-number: QTCREATORBUG-6494 Change-Id: I35f52761791af697eabb569adb5faee6fae50638 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qobject.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index c96fb446d6..617fadc1ab 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -3219,6 +3219,9 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender,
\snippet code/src_corelib_kernel_qobject.cpp 34
+ If \a object itself has a properly set object name, its own signals are also
+ connected to its respective slots.
+
\sa QObject::setObjectName()
*/
void QMetaObject::connectSlotsByName(QObject *o)
@@ -3227,7 +3230,10 @@ void QMetaObject::connectSlotsByName(QObject *o)
return;
const QMetaObject *mo = o->metaObject();
Q_ASSERT(mo);
- const QObjectList list = o->findChildren<QObject *>(QString());
+ const QObjectList list = // list of all objects to look for matching signals including...
+ o->findChildren<QObject *>(QString()) // all children of 'o'...
+ << o; // and the object 'o' itself
+
for (int i = 0; i < mo->methodCount(); ++i) {
QByteArray slotSignature = mo->method(i).methodSignature();
const char *slot = slotSignature.constData();