From 06ec705098458d1f71addb77dcb0bb1ee9b7f5bc Mon Sep 17 00:00:00 2001 From: Adrien Moulin Date: Thu, 25 Aug 2022 22:25:11 +0200 Subject: [PATCH 1/2] qt: fix duplicate entries in network settings --- src/qt/qt_settingsnetwork.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 7bf26b263..8c4c82904 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -116,11 +116,13 @@ void SettingsNetwork::onCurrentMachineChanged(int machineId) { cbox = findChild(QString("comboBoxNet%1").arg(i+1)); model = cbox->model(); + removeRows = model->rowCount(); Models::AddEntry(model, tr("None"), NET_TYPE_NONE); Models::AddEntry(model, "SLiRP", NET_TYPE_SLIRP); if (network_ndev > 1) { Models::AddEntry(model, "PCap", NET_TYPE_PCAP); } + model->removeRows(0, removeRows); cbox->setCurrentIndex(net_cards_conf[i].net_type); selectedRow = 0; @@ -128,12 +130,14 @@ void SettingsNetwork::onCurrentMachineChanged(int machineId) { QString currentPcapDevice = net_cards_conf[i].host_dev_name; cbox = findChild(QString("comboBoxIntf%1").arg(i+1)); model = cbox->model(); + removeRows = model->rowCount(); for (int c = 0; c < network_ndev; c++) { Models::AddEntry(model, tr(network_devs[c].description), c); if (QString(network_devs[c].device) == currentPcapDevice) { selectedRow = c; } } + model->removeRows(0, removeRows); cbox->setCurrentIndex(selectedRow); } } From 9ad587dbfd8735f62d6a0a6162f15e7f0255ed79 Mon Sep 17 00:00:00 2001 From: Adrien Moulin Date: Thu, 25 Aug 2022 23:53:09 +0200 Subject: [PATCH 2/2] qt: fix instance number not set when editing nic config --- src/qt/qt_settingsnetwork.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 8c4c82904..1cb42cc22 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -151,17 +151,17 @@ void SettingsNetwork::on_comboIndexChanged(int index) { } void SettingsNetwork::on_pushButtonConf1_clicked() { - DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxNIC1->currentData().toInt()), 0, qobject_cast(Settings::settings)); + DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxNIC1->currentData().toInt()), 1, qobject_cast(Settings::settings)); } void SettingsNetwork::on_pushButtonConf2_clicked() { - DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxNIC2->currentData().toInt()), 0, qobject_cast(Settings::settings)); + DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxNIC2->currentData().toInt()), 2, qobject_cast(Settings::settings)); } void SettingsNetwork::on_pushButtonConf3_clicked() { - DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxNIC3->currentData().toInt()), 0, qobject_cast(Settings::settings)); + DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxNIC3->currentData().toInt()), 3, qobject_cast(Settings::settings)); } void SettingsNetwork::on_pushButtonConf4_clicked() { - DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxNIC4->currentData().toInt()), 0, qobject_cast(Settings::settings)); + DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxNIC4->currentData().toInt()), 4, qobject_cast(Settings::settings)); }