diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-05-31 21:18:34 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-03 11:04:50 +0200 |
commit | 6d996dd74d80b763fa1c835453c3fb18832be050 (patch) | |
tree | 5522657372c847661462205b9b912552d1ade88d /src/corelib | |
parent | 0d86ca432ae39574dd644de1ebc73597a2e43974 (diff) |
Change QConnectionSenderSwitcher et al to use signal index range
First step towards getting rid of the signal_absolute_index variable
from QMetaObject::activate() (which requires computation of the
class's method offset).
This also required changing the implementation of the public function
senderSignalIndex() so it still returns an index in the full method
range.
Change-Id: I58571eb3c8099ea5b673682872c53875f5ea8c13
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 20 | ||||
-rw-r--r-- | src/corelib/kernel/qobject_p.h | 3 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 565d5ec707..ae96fffcec 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2134,7 +2134,11 @@ QObject *QObject::sender() const int QObject::senderSignalIndex() const { Q_D(const QObject); - return d->senderSignalIndex(); + int signal_index = d->senderSignalIndex(); + if (signal_index < 0) + return signal_index; + // Convert from signal range to method range + return QMetaObjectPrivate::signal(sender()->metaObject(), signal_index).methodIndex(); } /*! @@ -3230,11 +3234,15 @@ void QMetaObject::connectSlotsByName(QObject *o) } } +/*! \internal + + \a signal must be in the signal index range (see QObjectPrivate::signalIndex()). +*/ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv) { const int *argumentTypes = c->argumentTypes.load(); if (!argumentTypes && argumentTypes != &DIRECT_CONNECTION_ONLY) { - QMetaMethod m = sender->metaObject()->method(signal); + QMetaMethod m = QMetaObjectPrivate::signal(sender->metaObject(), signal); argumentTypes = queuedConnectionTypes(m.parameterTypes()); if (!argumentTypes) // cannot queue arguments argumentTypes = &DIRECT_CONNECTION_ONLY; @@ -3357,7 +3365,7 @@ void QMetaObject::activate(QObject *sender, int methodOffset, int signalOffset, // put into the event queue if ((c->connectionType == Qt::AutoConnection && !receiverInSameThread) || (c->connectionType == Qt::QueuedConnection)) { - queued_activate(sender, signal_absolute_index, c, argv ? argv : empty_argv); + queued_activate(sender, signal_index, c, argv ? argv : empty_argv); continue; #ifndef QT_NO_THREAD } else if (c->connectionType == Qt::BlockingQueuedConnection) { @@ -3370,8 +3378,8 @@ void QMetaObject::activate(QObject *sender, int methodOffset, int signalOffset, } QSemaphore semaphore; QMetaCallEvent *ev = c->isSlotObject ? - new QMetaCallEvent(c->slotObj, sender, signal_absolute_index, 0, 0, argv ? argv : empty_argv, &semaphore) : - new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal_absolute_index, 0, 0, argv ? argv : empty_argv, &semaphore); + new QMetaCallEvent(c->slotObj, sender, signal_index, 0, 0, argv ? argv : empty_argv, &semaphore) : + new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal_index, 0, 0, argv ? argv : empty_argv, &semaphore); QCoreApplication::postEvent(receiver, ev); semaphore.acquire(); locker.relock(); @@ -3382,7 +3390,7 @@ void QMetaObject::activate(QObject *sender, int methodOffset, int signalOffset, QConnectionSenderSwitcher sw; if (receiverInSameThread) { - sw.switchSender(receiver, sender, signal_absolute_index); + sw.switchSender(receiver, sender, signal_index); } const QObjectPrivate::StaticMetaCallFunction callFunction = c->callFunction; const int method_relative = c->method_relative; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 84e2ecd779..8121e74245 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -258,6 +258,9 @@ class Q_CORE_EXPORT QMetaCallEvent : public QEvent public: QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction , const QObject *sender, int signalId, int nargs = 0, int *types = 0, void **args = 0, QSemaphore *semaphore = 0); + /*! \internal + \a signalId is in the signal index range (see QObjectPrivate::signalIndex()). + */ QMetaCallEvent(QObject::QSlotObjectBase *slotObj, const QObject *sender, int signalId, int nargs = 0, int *types = 0, void **args = 0, QSemaphore *semaphore = 0); |