mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-10-09 02:31:42 -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:
1 parent
79eb758a52
commit
d9b0995b44
2 files changed
+12
-6
No files matched your search
@@ -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