Fix crash on close while detecting devices

This commit is contained in:
Térence Clastres 2020-08-06 18:19:59 +02:00 committed by Adam Honse
parent 06b2cd87c6
commit f8af9980fd
4 changed files with 21 additions and 0 deletions

View file

@ -106,6 +106,7 @@ void ResourceManager::DetectDevices()
void ResourceManager::DetectDevicesThreadFunction()
{
DetectDeviceMutex.lock();
unsigned int prev_count = 0;
float percent = 0.0f;
@ -175,4 +176,12 @@ void ResourceManager::DetectDevicesThreadFunction()
}
profile_manager.LoadSizeFromProfile("sizes.ors");
DetectDeviceMutex.unlock();
}
void ResourceManager::WaitForDeviceDetection()
{
DetectDeviceMutex.lock();
DetectDeviceMutex.unlock();
}

View file

@ -44,6 +44,8 @@ public:
void DetectDevicesThreadFunction();
void WaitForDeviceDetection();
private:
static std::unique_ptr<ResourceManager> instance;
@ -60,6 +62,8 @@ private:
std::thread * DetectDevicesThread;
std::mutex DetectDeviceMutex;
std::mutex DeviceListChangeMutex;
std::vector<ResourceManagerCallback> DeviceListChangeCallbacks;
std::vector<void *> DeviceListChangeCallbackArgs;

View file

@ -7,6 +7,7 @@
#include <QLabel>
#include <QTabBar>
#include <QMessageBox>
#include <QCloseEvent>
using namespace Ui;
@ -184,6 +185,12 @@ OpenRGBDialog2::~OpenRGBDialog2()
delete ui;
}
void OpenRGBDialog2::closeEvent(QCloseEvent *event)
{
ResourceManager::get()->WaitForDeviceDetection();
event->accept();
}
void OpenRGBDialog2::AddI2CToolsPage()
{
/*-----------------------------------------------------*\

View file

@ -66,6 +66,7 @@ private:
void ClearDevicesList();
void UpdateDevicesList();
void UpdateProfileList();
void closeEvent(QCloseEvent *event);
private slots:
void on_Exit();