From d9b0995b44a63a601a75c3080c2e8f7afd31d449 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 14 Jul 2026 11:55:52 -0500 Subject: [PATCH] Run RescanDevices in a background thread to avoid locking the UI thread and causing a deadlock in the plugins --- .../ManualDevicesSettingsPage.cpp | 11 +++++++---- qt/OpenRGBDialog/OpenRGBDialog.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/qt/ManualDevicesSettingsPage/ManualDevicesSettingsPage.cpp b/qt/ManualDevicesSettingsPage/ManualDevicesSettingsPage.cpp index 2237fdbcc..9f10768c2 100644 --- a/qt/ManualDevicesSettingsPage/ManualDevicesSettingsPage.cpp +++ b/qt/ManualDevicesSettingsPage/ManualDevicesSettingsPage.cpp @@ -8,6 +8,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ +#include #include "ManualDevicesSettingsPage.h" #include "ui_ManualDevicesSettingsPage.h" @@ -337,9 +338,11 @@ void ManualDevicesSettingsPage::on_ActionSaveAndRescan_triggered() { saveSettings(); - /*---------------------------------------------------------*\ - | Trigger rescan | - \*---------------------------------------------------------*/ - ResourceManager::get()->RescanDevices(); + /*-----------------------------------------------------*\ + | Run RescanDevices in an asynchronous thread to avoid | + | locking the UI thread | + \*-----------------------------------------------------*/ + std::thread rescan_thread([](){ResourceManager::get()->RescanDevices();}); + rescan_thread.detach(); } diff --git a/qt/OpenRGBDialog/OpenRGBDialog.cpp b/qt/OpenRGBDialog/OpenRGBDialog.cpp index 0d39959c2..bc20e9b5e 100644 --- a/qt/OpenRGBDialog/OpenRGBDialog.cpp +++ b/qt/OpenRGBDialog/OpenRGBDialog.cpp @@ -7,6 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ +#include #include "AutoStart.h" #include "OpenRGBDialog.h" #include "JsonUtils.h" @@ -2018,9 +2019,11 @@ void OpenRGBDialog::SaveProfileAs() void OpenRGBDialog::on_ButtonRescan_clicked() { /*-----------------------------------------------------*\ - | Rescan devices in ResourceManager | + | Run RescanDevices in an asynchronous thread to avoid | + | locking the UI thread | \*-----------------------------------------------------*/ - ResourceManager::get()->RescanDevices(); + std::thread rescan_thread([](){ResourceManager::get()->RescanDevices();}); + rescan_thread.detach(); } void OpenRGBDialog::on_ActionSaveProfile_triggered()