@@ -25,6 +25,20 @@
25#include <QDBusConnectionInterface>
25#include <QDBusConnectionInterface>
26#include <QDBusReply>
26#include <QDBusReply>
28+// On construction QDBusInterface synchronously introspects the service, which will block the GUI
29+// thread if the service is busy. QDBusAbstractInterface does not perform this introspection, so
30+// let's subclass that and avoid the blocking scenario.
31+class AsyncDBusInterface : public QDBusAbstractInterface
34+ AsyncDBusInterface(const QString &service, const QString &path,
35+ const QString &interface, const QDBusConnection &connection,
37+ : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent)
39+ ~AsyncDBusInterface() = default;
28AbstractDBusServiceMonitor::AbstractDBusServiceMonitor(const QString &service, const QString &path,
42AbstractDBusServiceMonitor::AbstractDBusServiceMonitor(const QString &service, const QString &path,
29 const QString &interface, const Bus bus,
43 const QString &interface, const Bus bus,
30 QObject *parent)
44 QObject *parent)
@@ -61,8 +75,8 @@ void AbstractDBusServiceMonitor::createInterface(const QString &)
61 m_dbusInterface = nullptr;
75 m_dbusInterface = nullptr;
64− m_dbusInterface = new QDBusInterface(m_service, m_path, m_interface,
78+ m_dbusInterface = new AsyncDBusInterface(m_service, m_path, m_interface,
65− QDBusConnection::sessionBus());
79+ QDBusConnection::sessionBus());
66 Q_EMIT serviceAvailableChanged(true);
80 Q_EMIT serviceAvailableChanged(true);
@@ -76,7 +90,7 @@ void AbstractDBusServiceMonitor::destroyInterface(const QString &)
76 Q_EMIT serviceAvailableChanged(false);
90 Q_EMIT serviceAvailableChanged(false);
79−QDBusInterface* AbstractDBusServiceMonitor::dbusInterface() const
93+QDBusAbstractInterface* AbstractDBusServiceMonitor::dbusInterface() const
81 return m_dbusInterface;
95 return m_dbusInterface;