From 5317ed796b033af5372a436bfbc608db0b3fdb50 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 7 May 2012 20:38:38 +0200 Subject: [PATCH] Device support: Fix bug in DeviceManagerModel. Yet another instance of using a potentially wrong index. Also check some invariants. Change-Id: I2306fe854481e85f38434ec73cf5e92675110bf1 Reviewed-by: Tobias Hunger --- .../projectexplorer/devicesupport/devicemanagermodel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp b/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp index 48594aa7b6c..6c0d9003edd 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp @@ -35,6 +35,7 @@ #include "devicemanager.h" #include +#include #include @@ -104,6 +105,7 @@ void DeviceManagerModel::handleDeviceAdded(Core::Id id) void DeviceManagerModel::handleDeviceRemoved(Core::Id id) { const int idx = indexForId(id); + QTC_ASSERT(idx != -1, return); beginRemoveRows(QModelIndex(), idx, idx); d->devices.removeAt(idx); endRemoveRows(); @@ -112,7 +114,8 @@ void DeviceManagerModel::handleDeviceRemoved(Core::Id id) void DeviceManagerModel::handleDeviceUpdated(Core::Id id) { const int idx = indexForId(id); - d->devices[idx] = d->deviceManager->deviceAt(idx); + QTC_ASSERT(idx != -1, return); + d->devices[idx] = d->deviceManager->find(id); const QModelIndex changedIndex = index(idx, 0); emit dataChanged(changedIndex, changedIndex); }