From 77d9a224195da97ff4847e8ed8affb4e64200e29 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Mon, 28 Mar 2022 20:15:29 +0200 Subject: [PATCH] Fix undefined behavior due to recursive mutex locking, and properly clear sensors when re-enumerating --- AdaptiveBrightness/main_window.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AdaptiveBrightness/main_window.cpp b/AdaptiveBrightness/main_window.cpp index ce88ee8..5ca4e6a 100644 --- a/AdaptiveBrightness/main_window.cpp +++ b/AdaptiveBrightness/main_window.cpp @@ -19,7 +19,7 @@ #include "sensor_driver.hpp" #include "utils.hpp" -MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) +MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), m_mtx(QMutex::RecursionMode::Recursive) { qDebug(ltr("Creating main window")); @@ -54,6 +54,8 @@ void MainWindow::closeEvent(QCloseEvent* event) void MainWindow::enumSensors() { + m_sensors.clear(); + auto sensors = enumerateSensors(); for(auto& sensor: sensors) {