diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-30 11:51:30 -0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-09-15 02:08:31 +0000 |
commit | 9af53bfc8115eab4a6f46e5b38527ed3b669f3f0 (patch) | |
tree | b94f15e674e4366ba58d3ac066ddd04330ffabee /src/dbus | |
parent | 1996bd4a01748ae384242eb47d4ff2c679c4c5d0 (diff) |
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>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusconnection_p.h | 1 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 14 |
2 files changed, 4 insertions, 11 deletions
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 9e948bd684..fde7edaa64 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -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); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 04d2c93ffe..84d433f2e7 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -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; |