mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-05 06:34:25 -04:00
Wait on asynchronous device detection before performing CLI operations that require device list
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
std::unique_ptr<ResourceManager> ResourceManager::instance;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
ResourceManager *ResourceManager::get()
|
||||
{
|
||||
@@ -22,15 +23,17 @@ ResourceManager::ResourceManager()
|
||||
|
||||
ResourceManager::~ResourceManager()
|
||||
{
|
||||
for(i2c_smbus_interface* bus : busses)
|
||||
{
|
||||
delete bus;
|
||||
}
|
||||
ResourceManager::get()->WaitForDeviceDetection();
|
||||
|
||||
for(RGBController* rgb_controller : rgb_controllers)
|
||||
{
|
||||
delete rgb_controller;
|
||||
}
|
||||
|
||||
for(i2c_smbus_interface* bus : busses)
|
||||
{
|
||||
//delete bus;
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceManager::RegisterI2CBus(i2c_smbus_interface *bus)
|
||||
@@ -108,6 +111,12 @@ void ResourceManager::DetectDevices()
|
||||
| Start the device detection thread |
|
||||
\*-------------------------------------------------*/
|
||||
DetectDevicesThread = new std::thread(&ResourceManager::DetectDevicesThreadFunction, this);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Release the current thread to allow detection |
|
||||
| thread to start |
|
||||
\*-------------------------------------------------*/
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
void ResourceManager::DetectDevicesThreadFunction()
|
||||
|
||||
Reference in New Issue
Block a user