PSUSensor: Fix rescan behavior
The original object needs to be destroyed instead
of using the move constructor so the dbus remove and
added messages happen in the right order.
Tested: Sensors available at boot
Change-Id: I1d95c4e9871c961d6b742f8d862555b6bd808cea
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index ef74aa3..6bfe3ad 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -257,7 +257,9 @@
std::get<std::string>(findPSUName->second) + " " +
findProperty->second.labelTypeName;
- sensors[sensorName] = std::make_unique<PSUSensor>(
+ auto& newSensor = sensors[sensorName];
+ newSensor = nullptr; // destroy old one if it exists
+ newSensor = std::make_unique<PSUSensor>(
sensorPathStr, sensorType, objectServer, dbusConnection, io,
sensorName, std::move(sensorThresholds), *interfacePath,
findSensorType->second, factor, findProperty->second.maxReading,