summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusconnectionmanager.cpp
diff options
context:
space:
mode:
authorIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2023-08-15 13:14:57 +0200
committerIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2023-08-21 12:18:33 +0200
commit7c9e61a3fe6da233571f24acf7ec9d9a8fc43210 (patch)
tree5fba00b8633e44a9f817b2bcf9128351cc1a9c8b /src/dbus/qdbusconnectionmanager.cpp
parent338de683950b3826edfc29c5d64da1df6b21a360 (diff)
QDBusConnectionManager: Use invokeMethod() to create servers
Use QMetaObject::invokeMethod() with a lambda instead of setting up a permanent signal/slot connections with BlockingQueuedConnection type. This makes the code flow easier to follow. Change-Id: Ib6566e7a4694ecbd69900b645d020b3331fb3462 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus/qdbusconnectionmanager.cpp')
-rw-r--r--src/dbus/qdbusconnectionmanager.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/dbus/qdbusconnectionmanager.cpp b/src/dbus/qdbusconnectionmanager.cpp
index 96d8d32185..02b35420c5 100644
--- a/src/dbus/qdbusconnectionmanager.cpp
+++ b/src/dbus/qdbusconnectionmanager.cpp
@@ -74,8 +74,6 @@ QDBusConnectionManager::QDBusConnectionManager()
connect(this, &QDBusConnectionManager::connectionRequested,
this, &QDBusConnectionManager::executeConnectionRequest, Qt::BlockingQueuedConnection);
- connect(this, &QDBusConnectionManager::serverRequested,
- this, &QDBusConnectionManager::createServer, Qt::BlockingQueuedConnection);
moveToThread(this); // ugly, don't do this in other projects
#ifdef Q_OS_WIN
@@ -223,12 +221,17 @@ void QDBusConnectionManager::executeConnectionRequest(QDBusConnectionManager::Co
}
}
-void QDBusConnectionManager::createServer(const QString &address, void *server)
+void QDBusConnectionManager::createServer(const QString &address, QDBusServer *server)
{
- QDBusErrorInternal error;
- QDBusConnectionPrivate *d = new QDBusConnectionPrivate;
- d->setServer(static_cast<QDBusServer *>(server),
- q_dbus_server_listen(address.toUtf8().constData(), error), error);
+ QMetaObject::invokeMethod(
+ this,
+ [&address, server] {
+ QDBusErrorInternal error;
+ QDBusConnectionPrivate *d = new QDBusConnectionPrivate;
+ d->setServer(server, q_dbus_server_listen(address.toUtf8().constData(), error),
+ error);
+ },
+ Qt::BlockingQueuedConnection);
}
QT_END_NAMESPACE