diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2019-05-08 18:33:55 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2019-05-08 18:52:06 +0000 |
commit | 14b5821f7b9998c1263c592d2cc70f21f1e72981 (patch) | |
tree | ffe662c6bb290ed9bbb443ce7b8165013d2da583 /src | |
parent | a4b7814ec945b979bafdc6de60800bbddd4d240e (diff) |
Do not register iio sensors if the dbus service is not found
Fixes: QTBUG-74905
Change-Id: I78ca045d2723fa47dc2d0f9cc559320be84e5f32
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/sensors/iio-sensor-proxy/main.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/plugins/sensors/iio-sensor-proxy/main.cpp b/src/plugins/sensors/iio-sensor-proxy/main.cpp index 136dd40e..580e2c46 100644 --- a/src/plugins/sensors/iio-sensor-proxy/main.cpp +++ b/src/plugins/sensors/iio-sensor-proxy/main.cpp @@ -46,6 +46,9 @@ #include <qsensorbackend.h> #include <qsensormanager.h> +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusConnectionInterface> + #include <QtCore/QFile> #include <QtCore/QDebug> @@ -57,12 +60,14 @@ class IIOSensorProxySensorPlugin : public QObject, public QSensorPluginInterface public: void registerSensors() override { - if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id)) - QSensorManager::registerBackend(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id, this); - if (!QSensorManager::isBackendRegistered(QLightSensor::type, IIOSensorProxyLightSensor::id)) - QSensorManager::registerBackend(QLightSensor::type, IIOSensorProxyLightSensor::id, this); - if (!QSensorManager::isBackendRegistered(QCompass::type, IIOSensorProxyCompass::id)) - QSensorManager::registerBackend(QCompass::type, IIOSensorProxyCompass::id, this); + if (QDBusConnection::systemBus().interface()->isServiceRegistered("net.hadess.SensorProxy")) { + if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id)) + QSensorManager::registerBackend(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id, this); + if (!QSensorManager::isBackendRegistered(QLightSensor::type, IIOSensorProxyLightSensor::id)) + QSensorManager::registerBackend(QLightSensor::type, IIOSensorProxyLightSensor::id, this); + if (!QSensorManager::isBackendRegistered(QCompass::type, IIOSensorProxyCompass::id)) + QSensorManager::registerBackend(QCompass::type, IIOSensorProxyCompass::id, this); + } } QSensorBackend *createBackend(QSensor *sensor) override |