Fix crash on close while detecting devices
This commit is contained in:
parent
06b2cd87c6
commit
f8af9980fd
4 changed files with 21 additions and 0 deletions
|
|
@ -106,6 +106,7 @@ void ResourceManager::DetectDevices()
|
||||||
|
|
||||||
void ResourceManager::DetectDevicesThreadFunction()
|
void ResourceManager::DetectDevicesThreadFunction()
|
||||||
{
|
{
|
||||||
|
DetectDeviceMutex.lock();
|
||||||
unsigned int prev_count = 0;
|
unsigned int prev_count = 0;
|
||||||
float percent = 0.0f;
|
float percent = 0.0f;
|
||||||
|
|
||||||
|
|
@ -175,4 +176,12 @@ void ResourceManager::DetectDevicesThreadFunction()
|
||||||
}
|
}
|
||||||
|
|
||||||
profile_manager.LoadSizeFromProfile("sizes.ors");
|
profile_manager.LoadSizeFromProfile("sizes.ors");
|
||||||
|
|
||||||
|
DetectDeviceMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourceManager::WaitForDeviceDetection()
|
||||||
|
{
|
||||||
|
DetectDeviceMutex.lock();
|
||||||
|
DetectDeviceMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ public:
|
||||||
|
|
||||||
void DetectDevicesThreadFunction();
|
void DetectDevicesThreadFunction();
|
||||||
|
|
||||||
|
void WaitForDeviceDetection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unique_ptr<ResourceManager> instance;
|
static std::unique_ptr<ResourceManager> instance;
|
||||||
|
|
||||||
|
|
@ -60,6 +62,8 @@ private:
|
||||||
|
|
||||||
std::thread * DetectDevicesThread;
|
std::thread * DetectDevicesThread;
|
||||||
|
|
||||||
|
std::mutex DetectDeviceMutex;
|
||||||
|
|
||||||
std::mutex DeviceListChangeMutex;
|
std::mutex DeviceListChangeMutex;
|
||||||
std::vector<ResourceManagerCallback> DeviceListChangeCallbacks;
|
std::vector<ResourceManagerCallback> DeviceListChangeCallbacks;
|
||||||
std::vector<void *> DeviceListChangeCallbackArgs;
|
std::vector<void *> DeviceListChangeCallbackArgs;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTabBar>
|
#include <QTabBar>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QCloseEvent>
|
||||||
|
|
||||||
using namespace Ui;
|
using namespace Ui;
|
||||||
|
|
||||||
|
|
@ -184,6 +185,12 @@ OpenRGBDialog2::~OpenRGBDialog2()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenRGBDialog2::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
ResourceManager::get()->WaitForDeviceDetection();
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
void OpenRGBDialog2::AddI2CToolsPage()
|
void OpenRGBDialog2::AddI2CToolsPage()
|
||||||
{
|
{
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ private:
|
||||||
void ClearDevicesList();
|
void ClearDevicesList();
|
||||||
void UpdateDevicesList();
|
void UpdateDevicesList();
|
||||||
void UpdateProfileList();
|
void UpdateProfileList();
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_Exit();
|
void on_Exit();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue