Run RescanDevices in a background thread to avoid locking the UI thread and causing a deadlock in the plugins

This commit is contained in:
Adam Honse
2026-07-14 11:55:52 -05:00
parent 79eb758a52
commit d9b0995b44
2 changed files with 12 additions and 6 deletions

View File

@@ -8,6 +8,7 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <thread>
#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();
}

View File

@@ -7,6 +7,7 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <thread>
#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()