Commit dbb656d5 authored by David Edmundson's avatar David Edmundson Committed by David Edmundson
Browse files

[ksgrd] Correctly handle monitors list changing

If ksgrd changes the monitors then all IDs are invalid.
This can happen when a new device is plugged in and removed.

SensorObjects can remain valid and are re-matched up.


(cherry picked from commit a7d1b0d9)
parent 889443f4
...@@ -97,6 +97,7 @@ void KSGRDIface::unsubscribe(const QString &sensorPath) ...@@ -97,6 +97,7 @@ void KSGRDIface::unsubscribe(const QString &sensorPath)
void KSGRDIface::updateMonitorsList() void KSGRDIface::updateMonitorsList()
{ {
m_sensorIds.clear();
KSGRD::SensorMgr->sendRequest(QStringLiteral("localhost"), QStringLiteral("monitors"), (KSGRD::SensorClient *)this, -1); KSGRD::SensorMgr->sendRequest(QStringLiteral("localhost"), QStringLiteral("monitors"), (KSGRD::SensorClient *)this, -1);
} }
...@@ -220,6 +221,10 @@ void KSGRDIface::onSensorUpdated(int id, const QList<QByteArray> &answer) ...@@ -220,6 +221,10 @@ void KSGRDIface::onSensorUpdated(int id, const QList<QByteArray> &answer)
{ {
m_waitingFor--; m_waitingFor--;
if (answer.isEmpty() || id > m_sensorIds.count()) {
return;
}
const QString sensorName = m_sensorIds.at(id); const QString sensorName = m_sensorIds.at(id);
if (sensorName.isEmpty()) { if (sensorName.isEmpty()) {
return; return;
......
Markdown is supported
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