Use a signal for updating the dispatch status
The cost of connecting a signal may be a bit high, but it's comparable to looking up the invokable method. However, QMetaMethod::invoke has a higher cost than a signal-slot emission -- though in any case they're both dwarfed by the cost of allocating the QMetaCallEvent and the posting of it. This is much more readable, though. Change-Id: Iccecbecbe6288fb3b6d16578fdff3f203b6db29c Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Albert Astals Cid <aacid@kde.org>
This commit is contained in:
parent
1996bd4a01
commit
9af53bfc81
@ -271,6 +271,7 @@ private slots:
|
||||
void unregisterServiceNoLock(const QString &serviceName);
|
||||
|
||||
signals:
|
||||
void dispatchStatusChanged();
|
||||
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
|
||||
void callWithCallbackFailed(const QDBusError &error, const QDBusMessage &message);
|
||||
void newServerConnection(QDBusConnectionPrivate *newConnection);
|
||||
|
@ -357,18 +357,8 @@ static void qDBusUpdateDispatchStatus(DBusConnection *connection, DBusDispatchSt
|
||||
Q_ASSERT(connection);
|
||||
Q_UNUSED(connection);
|
||||
QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(data);
|
||||
|
||||
static int slotId; // 0 is QObject::deleteLater()
|
||||
if (!slotId) {
|
||||
// it's ok to do this: there's no race condition because the store is atomic
|
||||
// and we always set to the same value
|
||||
slotId = QDBusConnectionPrivate::staticMetaObject.indexOfSlot("doDispatch()");
|
||||
}
|
||||
|
||||
//qDBusDebug() << "Updating dispatcher status" << slotId;
|
||||
if (new_status == DBUS_DISPATCH_DATA_REMAINS)
|
||||
QDBusConnectionPrivate::staticMetaObject.method(slotId).
|
||||
invoke(d, Qt::QueuedConnection);
|
||||
emit d->dispatchStatusChanged();
|
||||
}
|
||||
|
||||
static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, void *data)
|
||||
@ -1030,6 +1020,8 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
|
||||
#endif
|
||||
|
||||
QDBusMetaTypeId::init();
|
||||
connect(this, &QDBusConnectionPrivate::dispatchStatusChanged,
|
||||
this, &QDBusConnectionPrivate::doDispatch, Qt::QueuedConnection);
|
||||
|
||||
rootNode.flags = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user