diff --git a/orientation_sensor.h b/orientation_sensor.h --- a/orientation_sensor.h +++ b/orientation_sensor.h @@ -35,7 +35,6 @@ class KWIN_EXPORT OrientationSensor : public QObject { Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.OrientationSensor") Q_PROPERTY(bool userEnabled READ isUserEnabled WRITE setUserEnabled NOTIFY userEnabledChanged) public: explicit OrientationSensor(QObject *parent = nullptr); @@ -88,8 +87,6 @@ Orientation m_orientation = Orientation::Undefined; KStatusNotifierItem *m_sni = nullptr; KSharedConfig::Ptr m_config; - OrientationSensorAdaptor *m_adaptor = nullptr; - }; } diff --git a/orientation_sensor.cpp b/orientation_sensor.cpp --- a/orientation_sensor.cpp +++ b/orientation_sensor.cpp @@ -36,6 +36,8 @@ { connect(m_sensor, &QOrientationSensor::readingChanged, this, &OrientationSensor::updateState); connect(m_sensor, &QOrientationSensor::activeChanged, this, &OrientationSensor::refresh); + + new OrientationSensorAdaptor(this); } void OrientationSensor::updateState() @@ -133,12 +135,11 @@ if (m_enabled) { loadConfig(); refresh(); - m_adaptor = new OrientationSensorAdaptor(this); + QDBusConnection::sessionBus().registerObject(QStringLiteral("/Orientation"), this); } else { + QDBusConnection::sessionBus().unregisterObject(QStringLiteral("/Orientation")); delete m_sni; m_sni = nullptr; - delete m_adaptor; - m_adaptor = nullptr; } startStopSensor(); }