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

SensorDataModel: Do not insert columns that are out of range

It may happen that the metadata for a later column arrives before an
earlier one. In that case, we call beginInsertColumns with an out of
range column index.

This was verified to fix the the issue (and it still preserves the
correct order) by scrambling the metadata requests in `sensorsChanged()`
using std::shuffle and having the autotest still pass.

BUG: 433064
parent 2e2f52d2
...@@ -401,6 +401,12 @@ void SensorDataModel::onMetaDataChanged(const QString &sensorId, const SensorInf ...@@ -401,6 +401,12 @@ void SensorDataModel::onMetaDataChanged(const QString &sensorId, const SensorInf
} }
// Otherwise, it's a new sensor that was added // Otherwise, it's a new sensor that was added
// Ensure we do not insert columns that are out of range.
while (d->sensorInfos.count() + 1 <= column && column > 0) {
column--;
}
beginInsertColumns(QModelIndex{}, column, column); beginInsertColumns(QModelIndex{}, column, column);
d->sensorInfos[sensorId] = info; d->sensorInfos[sensorId] = info;
d->sensorData[sensorId] = QVariant{}; d->sensorData[sensorId] = QVariant{};
......
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