mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
[Hotfix] Led threads are now terminated correctly
This commit is contained in:
parent
5c632b5935
commit
c574be7b75
@ -51,13 +51,13 @@ void LedDeviceWrapper::createLedDevice(const QJsonObject& config)
|
|||||||
_ledDevice->moveToThread(thread);
|
_ledDevice->moveToThread(thread);
|
||||||
// setup thread management
|
// setup thread management
|
||||||
connect(thread, &QThread::started, _ledDevice, &LedDevice::start);
|
connect(thread, &QThread::started, _ledDevice, &LedDevice::start);
|
||||||
connect(thread, &QThread::finished, thread, &QObject::deleteLater);
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||||
connect(thread, &QThread::finished, _ledDevice, &QObject::deleteLater);
|
connect(thread, &QThread::finished, _ledDevice, &LedDevice::deleteLater);
|
||||||
|
|
||||||
// further signals
|
// further signals
|
||||||
connect(this, &LedDeviceWrapper::write, _ledDevice, &LedDevice::write);
|
connect(this, &LedDeviceWrapper::write, _ledDevice, &LedDevice::write, Qt::QueuedConnection);
|
||||||
connect(_hyperion->getMuxerInstance(), &PriorityMuxer::visiblePriorityChanged, _ledDevice, &LedDevice::visiblePriorityChanged);
|
connect(_hyperion->getMuxerInstance(), &PriorityMuxer::visiblePriorityChanged, _ledDevice, &LedDevice::visiblePriorityChanged, Qt::QueuedConnection);
|
||||||
connect(_ledDevice, &LedDevice::enableStateChanged, this, &LedDeviceWrapper::handleInternalEnableState);
|
connect(_ledDevice, &LedDevice::enableStateChanged, this, &LedDeviceWrapper::handleInternalEnableState, Qt::QueuedConnection);
|
||||||
|
|
||||||
// start the thread
|
// start the thread
|
||||||
thread->start();
|
thread->start();
|
||||||
@ -143,9 +143,17 @@ void LedDeviceWrapper::handleInternalEnableState(bool newState)
|
|||||||
|
|
||||||
void LedDeviceWrapper::stopDeviceThread()
|
void LedDeviceWrapper::stopDeviceThread()
|
||||||
{
|
{
|
||||||
|
// turns the leds off
|
||||||
_ledDevice->switchOff();
|
_ledDevice->switchOff();
|
||||||
|
|
||||||
|
// get current thread
|
||||||
QThread* oldThread = _ledDevice->thread();
|
QThread* oldThread = _ledDevice->thread();
|
||||||
delete _ledDevice; // fast desctruction
|
disconnect(oldThread, 0, 0, 0);
|
||||||
oldThread->quit(); // non blocking
|
oldThread->quit();
|
||||||
oldThread->wait();
|
oldThread->deleteLater();
|
||||||
|
oldThread = nullptr;
|
||||||
|
|
||||||
|
disconnect(_ledDevice, 0, 0, 0);
|
||||||
|
_ledDevice->deleteLater();
|
||||||
|
_ledDevice = nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user