summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2013-05-07 18:56:50 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-09 08:23:48 +0200
commit9cc106d9d7d951fcf30f4b0f8606afa6b50892ec (patch)
tree355982010d6eacc5352db0b10be1c6b180c6266c /src/corelib/kernel
parentbaa28220777774c619f132977f5d0f7cd0775226 (diff)
Fix a case of connect()ing to signals declared in a base class
Fix connection to pointer to member signal that belongs to the base class, but whose type is a pointer to a member of the derived class. The current code only use the QMetaObject of the type coming from the function type to look up the signal id. But if the signal was casted to a pointer to member function of a derived type, then we also need to look in the base classes Change-Id: Ib98fc38f63942946acb34d9f83c100991d58e4e5 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qobject.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 527a842d17..d4d2d527d4 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4288,9 +4288,13 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa
}
int signal_index = -1;
void *args[] = { &signal_index, signal };
- senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
- if (signal_index < 0 || signal_index >= QMetaObjectPrivate::get(senderMetaObject)->signalCount) {
- qWarning("QObject::connect: signal not found in %s", senderMetaObject->className());
+ for (; senderMetaObject && signal_index < 0; senderMetaObject = senderMetaObject->superClass()) {
+ senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
+ if (signal_index >= 0 && signal_index < QMetaObjectPrivate::get(senderMetaObject)->signalCount)
+ break;
+ }
+ if (!senderMetaObject) {
+ qWarning("QObject::connect: signal not found in %s", sender->metaObject()->className());
slotObj->destroyIfLastRef();
return QMetaObject::Connection(0);
}