From 597735ded641be0603da0b5dd1a90da9260bd065 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 29 Jun 2024 18:57:52 -0400 Subject: [PATCH] Fix null pointers in qt_settingsports.cpp --- src/qt/qt_settingsports.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index 9b19df68d..a675d7cdb 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -59,13 +59,16 @@ SettingsPorts::SettingsPorts(QWidget *parent) cbox->setCurrentIndex(selectedRow); auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); - checkBox->setChecked(lpt_ports[i].enabled > 0); - cbox->setEnabled(lpt_ports[i].enabled > 0); + if (checkBox != NULL) + checkBox->setChecked(lpt_ports[i].enabled > 0); + if (cBox != NULL) + cbox->setEnabled(lpt_ports[i].enabled > 0); } for (int i = 0; i < SERIAL_MAX; i++) { auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); - checkBox->setChecked(com_ports[i].enabled > 0); + if (checkBox != NULL) + checkBox->setChecked(com_ports[i].enabled > 0); } ui->checkBoxSerialPassThru1->setChecked(serial_passthrough_enabled[0]); @@ -89,13 +92,16 @@ SettingsPorts::save() for (int i = 0; i < PARALLEL_MAX; i++) { auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); - lpt_ports[i].device = cbox->currentData().toInt(); - lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0; + if (cBox != NULL) + lpt_ports[i].device = cbox->currentData().toInt(); + if (checkBox != NULL) + lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0; } for (int i = 0; i < SERIAL_MAX; i++) { auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); - com_ports[i].enabled = checkBox->isChecked() ? 1 : 0; + if (checkBox != NULL) + com_ports[i].enabled = checkBox->isChecked() ? 1 : 0; } serial_passthrough_enabled[0] = ui->checkBoxSerialPassThru1->isChecked();