Fix the LPT device list duplicating on every machine change

This commit is contained in:
Alexander Babikov
2025-03-08 10:14:58 +05:00
parent 02df55185f
commit 16d7bc26dc

View File

@@ -76,6 +76,7 @@ SettingsPorts::onCurrentMachineChanged(int machineId)
for (int i = 0; i < PARALLEL_MAX; i++) {
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
auto *model = cbox->model();
const auto removeRows = model->rowCount();
int c = 0;
int selectedRow = 0;
while (true) {
@@ -84,12 +85,15 @@ SettingsPorts::onCurrentMachineChanged(int machineId)
break;
}
Models::AddEntry(model, tr(lptName), c);
int row = Models::AddEntry(model, tr(lptName), c);
if (c == lpt_ports[i].device) {
selectedRow = c;
selectedRow = row - removeRows;
}
c++;
}
model->removeRows(0, removeRows);
cbox->setEnabled(model->rowCount() > 0);
cbox->setCurrentIndex(-1);
cbox->setCurrentIndex(selectedRow);
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));