forked from qt-creator/qt-creator
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 <tobias.hunger@nokia.com>
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ void DeviceManagerModel::handleDeviceAdded(Core::Id id)
|
|||||||
void DeviceManagerModel::handleDeviceRemoved(Core::Id id)
|
void DeviceManagerModel::handleDeviceRemoved(Core::Id id)
|
||||||
{
|
{
|
||||||
const int idx = indexForId(id);
|
const int idx = indexForId(id);
|
||||||
|
QTC_ASSERT(idx != -1, return);
|
||||||
beginRemoveRows(QModelIndex(), idx, idx);
|
beginRemoveRows(QModelIndex(), idx, idx);
|
||||||
d->devices.removeAt(idx);
|
d->devices.removeAt(idx);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
@@ -112,7 +114,8 @@ void DeviceManagerModel::handleDeviceRemoved(Core::Id id)
|
|||||||
void DeviceManagerModel::handleDeviceUpdated(Core::Id id)
|
void DeviceManagerModel::handleDeviceUpdated(Core::Id id)
|
||||||
{
|
{
|
||||||
const int idx = indexForId(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);
|
const QModelIndex changedIndex = index(idx, 0);
|
||||||
emit dataChanged(changedIndex, changedIndex);
|
emit dataChanged(changedIndex, changedIndex);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user