Join fan update thread before deleting fan tab

This commit is contained in:
Adam Honse
2020-08-08 21:51:56 -05:00
parent 73051af251
commit 188d8592ce
2 changed files with 5 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ OpenRGBFanPage::OpenRGBFanPage(FanController *dev, QWidget *parent) :
\*-----------------------------------------------------*/
device = dev;
fan_thread_running = true;
FanUpdateThread = new std::thread(&OpenRGBFanPage::FanUpdateThreadFunction, this);
QTimer *timer = new QTimer(this);
@@ -57,12 +58,14 @@ OpenRGBFanPage::OpenRGBFanPage(FanController *dev, QWidget *parent) :
OpenRGBFanPage::~OpenRGBFanPage()
{
fan_thread_running = false;
FanUpdateThread->join();
delete ui;
}
void OpenRGBFanPage::FanUpdateThreadFunction()
{
while(1)
while(fan_thread_running)
{
device->UpdateControl();
device->UpdateReading();

View File

@@ -36,6 +36,7 @@ private:
Ui::OpenRGBFanPageUi *ui;
FanController *device;
bool fan_thread_running;
std::thread* FanUpdateThread;
signals: