From 13e0d4e3376c552c2be2f99bad9a89f572bff215 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 21 Mar 2013 12:43:42 +0100 Subject: [PATCH] Device support: Make DeviceManager::setDefaultDevice take an id. This was the last DeviceManager function that still took an index, and like with all others, that lead to a bug due to device filtering. Task-number: QTCREATORBUG-7812 Change-Id: I4d5fbb7fa7a5b8238d343d231989452e8cf7e821 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/devicesupport/devicemanager.cpp | 6 +++--- src/plugins/projectexplorer/devicesupport/devicemanager.h | 2 +- .../projectexplorer/devicesupport/devicesettingswidget.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp index 16be85c5748..6a0f0861247 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp @@ -303,12 +303,12 @@ bool DeviceManager::isLoaded() const return d->writer; } -void DeviceManager::setDefaultDevice(int idx) +void DeviceManager::setDefaultDevice(Core::Id id) { QTC_ASSERT(this != instance(), return); - QTC_ASSERT(idx >= 0 && idx < deviceCount(), return); - const IDevice::ConstPtr &device = d->devices.at(idx); + const IDevice::ConstPtr &device = find(id); + QTC_ASSERT(device, return); const IDevice::ConstPtr &oldDefaultDevice = defaultDevice(device->type()); if (device == oldDefaultDevice) return; diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.h b/src/plugins/projectexplorer/devicesupport/devicemanager.h index 8fc16631a25..d57f3074060 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.h +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.h @@ -94,7 +94,7 @@ private: // For SettingsWidget. IDevice::Ptr mutableDevice(Core::Id id) const; - void setDefaultDevice(int index); + void setDefaultDevice(Core::Id id); static DeviceManager *cloneInstance(); static void replaceInstance(); static void removeClonedInstance(); diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp index 4882eb01545..fc5e572d524 100644 --- a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp @@ -268,7 +268,7 @@ void DeviceSettingsWidget::deviceNameEditingFinished() void DeviceSettingsWidget::setDefaultDevice() { - m_deviceManager->setDefaultDevice(currentIndex()); + m_deviceManager->setDefaultDevice(currentDevice()->id()); m_ui->defaultDeviceButton->setEnabled(false); }