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 <tobias.hunger@digia.com>
This commit is contained in:
Christian Kandeler
2013-03-21 12:43:42 +01:00
parent 03398ff8cf
commit 13e0d4e337
3 changed files with 5 additions and 5 deletions

View File

@@ -303,12 +303,12 @@ bool DeviceManager::isLoaded() const
return d->writer; return d->writer;
} }
void DeviceManager::setDefaultDevice(int idx) void DeviceManager::setDefaultDevice(Core::Id id)
{ {
QTC_ASSERT(this != instance(), return); 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()); const IDevice::ConstPtr &oldDefaultDevice = defaultDevice(device->type());
if (device == oldDefaultDevice) if (device == oldDefaultDevice)
return; return;

View File

@@ -94,7 +94,7 @@ private:
// For SettingsWidget. // For SettingsWidget.
IDevice::Ptr mutableDevice(Core::Id id) const; IDevice::Ptr mutableDevice(Core::Id id) const;
void setDefaultDevice(int index); void setDefaultDevice(Core::Id id);
static DeviceManager *cloneInstance(); static DeviceManager *cloneInstance();
static void replaceInstance(); static void replaceInstance();
static void removeClonedInstance(); static void removeClonedInstance();

View File

@@ -268,7 +268,7 @@ void DeviceSettingsWidget::deviceNameEditingFinished()
void DeviceSettingsWidget::setDefaultDevice() void DeviceSettingsWidget::setDefaultDevice()
{ {
m_deviceManager->setDefaultDevice(currentIndex()); m_deviceManager->setDefaultDevice(currentDevice()->id());
m_ui->defaultDeviceButton->setEnabled(false); m_ui->defaultDeviceButton->setEnabled(false);
} }