summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-04-08 12:55:16 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2011-04-08 13:12:34 (GMT)
commitdd60cf7ba8afdf5c84f5793c1e1d08ab18303a74 (patch)
treea0fbb6503aa28868e1ee284ebdb8ab080f3289a2 /src/corelib/kernel
parent51900ce698f7873eeabcd8723e61198a2c8d854d (diff)
downloadQt-dd60cf7ba8afdf5c84f5793c1e1d08ab18303a74.zip
Qt-dd60cf7ba8afdf5c84f5793c1e1d08ab18303a74.tar.gz
Qt-dd60cf7ba8afdf5c84f5793c1e1d08ab18303a74.tar.bz2
Use the qt_static_metacall in QueuedConnection
And also in QMetaMethod::invoke Reviewed-by: brad
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qmetaobject.cpp18
-rw-r--r--src/corelib/kernel/qobject.cpp31
-rw-r--r--src/corelib/kernel/qobject_p.h10
3 files changed, 38 insertions, 21 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index f0426f5..e671056 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -1625,9 +1625,19 @@ bool QMetaMethod::invoke(QObject *object,
val9.data()
};
// recompute the methodIndex by reversing the arithmetic in QMetaObject::property()
- int methodIndex = ((handle - priv(mobj->d.data)->methodData) / 5) + mobj->methodOffset();
+ int idx_relative = ((handle - priv(mobj->d.data)->methodData) / 5);
+ int idx_offset = mobj->methodOffset();
+ QObjectPrivate::StaticMetaCallFunction callFunction =
+ (QMetaObjectPrivate::get(mobj)->revision >= 6 && mobj->d.extradata)
+ ? reinterpret_cast<const QMetaObjectExtraData *>(mobj->d.extradata)->static_metacall : 0;
+
if (connectionType == Qt::DirectConnection) {
- return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, methodIndex, param) < 0;
+ if (callFunction) {
+ callFunction(object, QMetaObject::InvokeMetaMethod, idx_relative, param);
+ return true;
+ } else {
+ return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, idx_relative + idx_offset, param) < 0;
+ }
} else if (connectionType == Qt::QueuedConnection) {
if (returnValue.data()) {
qWarning("QMetaMethod::invoke: Unable to invoke methods with return values in "
@@ -1661,7 +1671,7 @@ bool QMetaMethod::invoke(QObject *object,
}
}
- QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex,
+ QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
0, -1, nargs, types, args));
} else { // blocking queued connection
#ifndef QT_NO_THREAD
@@ -1672,7 +1682,7 @@ bool QMetaMethod::invoke(QObject *object,
}
QSemaphore semaphore;
- QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex,
+ QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
0, -1, 0, 0, param, &semaphore));
semaphore.acquire();
#endif // QT_NO_THREAD
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 4cbeee2..357cfd3 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -490,10 +490,12 @@ void QObjectPrivate::clearGuards(QObject *object)
/*! \internal
*/
-QMetaCallEvent::QMetaCallEvent(int id, const QObject *sender, int signalId,
+QMetaCallEvent::QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction,
+ const QObject *sender, int signalId,
int nargs, int *types, void **args, QSemaphore *semaphore)
- : QEvent(MetaCall), id_(id), sender_(sender), signalId_(signalId),
- nargs_(nargs), types_(types), args_(args), semaphore_(semaphore)
+ : QEvent(MetaCall), sender_(sender), signalId_(signalId),
+ nargs_(nargs), types_(types), args_(args), semaphore_(semaphore),
+ callFunction_(callFunction), method_offset_(method_offset), method_relative_(method_relative)
{ }
/*! \internal
@@ -516,9 +518,13 @@ QMetaCallEvent::~QMetaCallEvent()
/*! \internal
*/
-int QMetaCallEvent::placeMetaCall(QObject *object)
+void QMetaCallEvent::placeMetaCall(QObject *object)
{
- return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, id_, args_);
+ if (callFunction_) {
+ callFunction_(object, QMetaObject::InvokeMetaMethod, method_relative_, args_);
+ } else {
+ QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, method_offset_ + method_relative_, args_);
+ }
}
/*!
@@ -3445,12 +3451,11 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
args[0] = 0; // return value
for (int n = 1; n < nargs; ++n)
args[n] = QMetaType::construct((types[n] = c->argumentTypes[n-1]), argv[n]);
- QCoreApplication::postEvent(c->receiver, new QMetaCallEvent(c->method(),
- sender,
- signal,
- nargs,
- types,
- args));
+ QCoreApplication::postEvent(c->receiver, new QMetaCallEvent(c->method_offset,
+ c->method_relative,
+ c->callFunction,
+ sender, signal, nargs,
+ types, args));
}
@@ -3530,7 +3535,6 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
continue;
#ifndef QT_NO_THREAD
} else if (c->connectionType == Qt::BlockingQueuedConnection) {
- const int method = c->method();
locker.unlock();
if (receiverInSameThread) {
qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: "
@@ -3539,7 +3543,8 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
receiver->metaObject()->className(), receiver);
}
QSemaphore semaphore;
- QCoreApplication::postEvent(receiver, new QMetaCallEvent(method,
+ QCoreApplication::postEvent(receiver, new QMetaCallEvent(c->method_offset, c->method_relative,
+ c->callFunction,
sender, signal_absolute_index,
0, 0,
argv ? argv : empty_argv,
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 71b5bee..2711a4b 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -257,25 +257,27 @@ class QSemaphore;
class Q_CORE_EXPORT QMetaCallEvent : public QEvent
{
public:
- QMetaCallEvent(int id, const QObject *sender, int signalId,
+ 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);
~QMetaCallEvent();
- inline int id() const { return id_; }
+ inline int id() const { return method_offset_ + method_relative_; }
inline const QObject *sender() const { return sender_; }
inline int signalId() const { return signalId_; }
inline void **args() const { return args_; }
- virtual int placeMetaCall(QObject *object);
+ virtual void placeMetaCall(QObject *object);
private:
- int id_;
const QObject *sender_;
int signalId_;
int nargs_;
int *types_;
void **args_;
QSemaphore *semaphore_;
+ QObjectPrivate::StaticMetaCallFunction callFunction_;
+ ushort method_offset_;
+ ushort method_relative_;
};
class QBoolBlocker