Fix null pointers in qt_settingsports.cpp

This commit is contained in:
Jasmine Iwanek
2024-06-29 18:57:52 -04:00
committed by GitHub
parent 970242e24a
commit 597735ded6

View File

@@ -59,12 +59,15 @@ SettingsPorts::SettingsPorts(QWidget *parent)
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));
if (checkBox != NULL)
checkBox->setChecked(lpt_ports[i].enabled > 0); checkBox->setChecked(lpt_ports[i].enabled > 0);
if (cBox != NULL)
cbox->setEnabled(lpt_ports[i].enabled > 0); cbox->setEnabled(lpt_ports[i].enabled > 0);
} }
for (int i = 0; i < SERIAL_MAX; i++) { for (int i = 0; i < SERIAL_MAX; i++) {
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1)); auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1));
if (checkBox != NULL)
checkBox->setChecked(com_ports[i].enabled > 0); checkBox->setChecked(com_ports[i].enabled > 0);
} }
@@ -89,12 +92,15 @@ SettingsPorts::save()
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 *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1)); auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
if (cBox != NULL)
lpt_ports[i].device = cbox->currentData().toInt(); lpt_ports[i].device = cbox->currentData().toInt();
if (checkBox != NULL)
lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0; lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
} }
for (int i = 0; i < SERIAL_MAX; i++) { for (int i = 0; i < SERIAL_MAX; i++) {
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1)); auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1));
if (checkBox != NULL)
com_ports[i].enabled = checkBox->isChecked() ? 1 : 0; com_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
} }