mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-07-29 14:36:06 -04:00
Run RescanDevices in a background thread to avoid locking the UI thread and causing a deadlock in the plugins
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user