Fix the LPT device list duplicating on every machine change
This commit is contained in:
@@ -74,22 +74,26 @@ SettingsPorts::onCurrentMachineChanged(int machineId)
|
|||||||
this->machineId = machineId;
|
this->machineId = machineId;
|
||||||
|
|
||||||
for (int i = 0; i < PARALLEL_MAX; i++) {
|
for (int i = 0; i < PARALLEL_MAX; i++) {
|
||||||
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
|
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
|
||||||
auto *model = cbox->model();
|
auto *model = cbox->model();
|
||||||
int c = 0;
|
const auto removeRows = model->rowCount();
|
||||||
int selectedRow = 0;
|
int c = 0;
|
||||||
|
int selectedRow = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
const char *lptName = lpt_device_get_name(c);
|
const char *lptName = lpt_device_get_name(c);
|
||||||
if (lptName == nullptr) {
|
if (lptName == nullptr) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Models::AddEntry(model, tr(lptName), c);
|
int row = Models::AddEntry(model, tr(lptName), c);
|
||||||
if (c == lpt_ports[i].device) {
|
if (c == lpt_ports[i].device) {
|
||||||
selectedRow = c;
|
selectedRow = row - removeRows;
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
model->removeRows(0, removeRows);
|
||||||
|
cbox->setEnabled(model->rowCount() > 0);
|
||||||
|
cbox->setCurrentIndex(-1);
|
||||||
cbox->setCurrentIndex(selectedRow);
|
cbox->setCurrentIndex(selectedRow);
|
||||||
|
|
||||||
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
|
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
|
||||||
|
|||||||
Reference in New Issue
Block a user