@@ -25,6 +25,20 @@
2525#include <QDBusConnectionInterface>
2626#include <QDBusReply>
2727
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
32+{
33+public:
34+ AsyncDBusInterface(const QString &service, const QString &path,
35+ const QString &interface, const QDBusConnection &connection,
36+ QObject *parent = 0)
37+ : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent)
38+ {}
39+ ~AsyncDBusInterface() = default;
40+};
41+
2842AbstractDBusServiceMonitor::AbstractDBusServiceMonitor(const QString &service, const QString &path,
2943 const QString &interface, const Bus bus,
3044 QObject *parent)
@@ -61,8 +75,8 @@ void AbstractDBusServiceMonitor::createInterface(const QString &)
6175 m_dbusInterface = nullptr;
6276 }
6377
64− m_dbusInterface = new QDBusInterface(m_service, m_path, m_interface,
65− QDBusConnection::sessionBus());
78+ m_dbusInterface = new AsyncDBusInterface(m_service, m_path, m_interface,
79+ QDBusConnection::sessionBus());
6680 Q_EMIT serviceAvailableChanged(true);
6781}
6882
@@ -76,7 +90,7 @@ void AbstractDBusServiceMonitor::destroyInterface(const QString &)
7690 Q_EMIT serviceAvailableChanged(false);
7791}
7892
79−QDBusInterface* AbstractDBusServiceMonitor::dbusInterface() const
93+QDBusAbstractInterface* AbstractDBusServiceMonitor::dbusInterface() const
8094{
8195 return m_dbusInterface;
8296}