summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--src/dbus/qdbusintegrator.cpp3
-rw-r--r--src/dbus/qdbusintegrator_p.h9
5 files changed, 43 insertions, 28 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
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index ee917a5..5f4dadd 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -1515,7 +1515,7 @@ QDBusActivateObjectEvent::~QDBusActivateObjectEvent()
// semaphore releasing happens in ~QMetaCallEvent
}
-int QDBusActivateObjectEvent::placeMetaCall(QObject *)
+void QDBusActivateObjectEvent::placeMetaCall(QObject *)
{
QDBusConnectionPrivate *that = QDBusConnectionPrivate::d(connection);
@@ -1526,7 +1526,6 @@ int QDBusActivateObjectEvent::placeMetaCall(QObject *)
QDBusLockerBase::AfterDeliver, that);
handled = true;
- return -1;
}
void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage& msg)
diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h
index 4047c24..59255f9 100644
--- a/src/dbus/qdbusintegrator_p.h
+++ b/src/dbus/qdbusintegrator_p.h
@@ -95,13 +95,12 @@ class QDBusCallDeliveryEvent: public QMetaCallEvent
public:
QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender,
const QDBusMessage &msg, const QList<int> &types, int f = 0)
- : QMetaCallEvent(id, sender, -1), connection(c), message(msg), metaTypes(types), flags(f)
+ : QMetaCallEvent(0, id, 0, sender, -1), connection(c), message(msg), metaTypes(types), flags(f)
{ }
- int placeMetaCall(QObject *object)
+ void placeMetaCall(QObject *object)
{
QDBusConnectionPrivate::d(connection)->deliverCall(object, flags, message, metaTypes, id());
- return -1;
}
private:
@@ -117,12 +116,12 @@ public:
QDBusActivateObjectEvent(const QDBusConnection &c, QObject *sender,
const QDBusConnectionPrivate::ObjectTreeNode &n,
int p, const QDBusMessage &m, QSemaphore *s = 0)
- : QMetaCallEvent(-1, sender, -1, 0, 0, 0, s), connection(c), node(n),
+ : QMetaCallEvent(0, -1, 0, sender, -1, 0, 0, 0, s), connection(c), node(n),
pathStartPos(p), message(m), handled(false)
{ }
~QDBusActivateObjectEvent();
- int placeMetaCall(QObject *);
+ void placeMetaCall(QObject *);
private:
QDBusConnection connection; // just for refcounting