Commit f2a09fc6 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Check initial value is valid before resetting in SensorProperty::unsubscribe

This way, we only reset the value if we originally got a valid value.
This allows us to indicate what behaviour we want when constructing the
SensorProperty. Some documentation has been added about that to the
relevant constructor.

CCBUG: 446414
parent a1ec6b8d
......@@ -183,7 +183,9 @@ void SensorProperty::unsubscribe()
if (d->subscribers == 0) {
if (d->initialValue.isValid()) {
Q_EMIT subscribedChanged(false);
......@@ -25,6 +25,19 @@ class SYSTEMSTATS_EXPORT SensorProperty : public QObject
explicit SensorProperty(const QString &id, SensorObject *parent);
explicit SensorProperty(const QString &id, const QString &name, SensorObject *parent);
* Construct a SensorProperty.
* \param id The unique ID of this SensorProperty.
* \param name The user-visible name of this SensorProperty.
* \param initialValue The value that is used when no other value has been set.
* \param parent The SensorObject that contains this SensorProperty.
* \note If initialValue is valid, the value of this SensorProperty will be
* reset to initialValue when the last client unsubscribes from this
* SensorProperty.
explicit SensorProperty(const QString &id, const QString &name, const QVariant &initalValue, SensorObject *parent);
~SensorProperty() override;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment