Segmentation Fault when attempting to detect or dump SMBus devices when none have been found
I realize there is some setup required to get SMBus devices functioning properly, but I think the case where these devices are not properly initialized should be handled, as well.
I've found that if SMBusAdaptersBox is empty, and I attempt to detect or dump SMBus devices, the application throws a segfault.
Something quick and dirty like this seemed to "resolve" the issue (only for the "Detect" button, obviously), though I'm totally unsure if there's a cleaner solution
diff --git a/qt/OpenRGBSystemInfoPage.cpp b/qt/OpenRGBSystemInfoPage.cpp
index a3efff7..6de9a37 100644
--- a/qt/OpenRGBSystemInfoPage.cpp
+++ b/qt/OpenRGBSystemInfoPage.cpp
@@ -1,5 +1,7 @@
#include "OpenRGBSystemInfoPage.h"
#include "i2c_tools.h"
+#include <iostream>
+#include <QMessageBox>
using namespace Ui;
@@ -37,6 +39,14 @@ OpenRGBSystemInfoPage::~OpenRGBSystemInfoPage()
void Ui::OpenRGBSystemInfoPage::on_DetectButton_clicked()
{
+ int adaptersCount = ui->SMBusAdaptersBox->count();
+ std::cout << "SMBus Adapters Box currently has " << adaptersCount << " items" << std::endl;
+ if (adaptersCount < 1) {
+ QMessageBox msgBox;
+ msgBox.setText("SMBusAdaptersBox is currently empty. Please fix this.");
+ msgBox.exec();
+ return;
+ }
i2c_smbus_interface* bus = busses[ui->SMBusAdaptersBox->currentIndex()];
ui->SMBusDataText->setPlainText(i2c_detect(bus, MODE_QUICK).c_str());
I did a brief issue search, but I apologize if I overlooked this problem in an existing issue.
Edited by Evan Stoll