fix(streamer-mode): destroy timer on correct thread (#5571)
This commit is contained in:
@@ -79,6 +79,7 @@
|
|||||||
- Dev: Fixed benchmarks segfaulting on run. (#5559)
|
- Dev: Fixed benchmarks segfaulting on run. (#5559)
|
||||||
- Dev: Refactored `MessageBuilder` to be a single class. (#5548)
|
- Dev: Refactored `MessageBuilder` to be a single class. (#5548)
|
||||||
- Dev: Recent changes are now shown in the nightly release description. (#5553, #5554)
|
- Dev: Recent changes are now shown in the nightly release description. (#5553, #5554)
|
||||||
|
- Dev: The timer for `StreamerMode` is now destroyed on the correct thread. (#5571)
|
||||||
|
|
||||||
## 2.5.1
|
## 2.5.1
|
||||||
|
|
||||||
|
|||||||
@@ -177,8 +177,8 @@ private:
|
|||||||
StreamerMode *parent_;
|
StreamerMode *parent_;
|
||||||
pajlada::Signals::SignalHolder settingConnections_;
|
pajlada::Signals::SignalHolder settingConnections_;
|
||||||
|
|
||||||
QTimer timer_;
|
|
||||||
QThread thread_;
|
QThread thread_;
|
||||||
|
QTimer *timer_;
|
||||||
|
|
||||||
std::atomic<bool> enabled_ = false;
|
std::atomic<bool> enabled_ = false;
|
||||||
mutable std::atomic<uint8_t> timeouts_ = 0;
|
mutable std::atomic<uint8_t> timeouts_ = 0;
|
||||||
@@ -209,10 +209,11 @@ void StreamerMode::start()
|
|||||||
|
|
||||||
StreamerModePrivate::StreamerModePrivate(StreamerMode *parent)
|
StreamerModePrivate::StreamerModePrivate(StreamerMode *parent)
|
||||||
: parent_(parent)
|
: parent_(parent)
|
||||||
|
, timer_(new QTimer(&this->thread_))
|
||||||
{
|
{
|
||||||
this->thread_.setObjectName("StreamerMode");
|
this->thread_.setObjectName("StreamerMode");
|
||||||
this->timer_.moveToThread(&this->thread_);
|
this->timer_->moveToThread(&this->thread_);
|
||||||
QObject::connect(&this->timer_, &QTimer::timeout, [this] {
|
QObject::connect(this->timer_, &QTimer::timeout, [this] {
|
||||||
auto timeouts =
|
auto timeouts =
|
||||||
this->timeouts_.fetch_add(1, std::memory_order::relaxed);
|
this->timeouts_.fetch_add(1, std::memory_order::relaxed);
|
||||||
if (timeouts < SKIPPED_TIMEOUTS)
|
if (timeouts < SKIPPED_TIMEOUTS)
|
||||||
@@ -244,6 +245,8 @@ void StreamerModePrivate::start()
|
|||||||
|
|
||||||
StreamerModePrivate::~StreamerModePrivate()
|
StreamerModePrivate::~StreamerModePrivate()
|
||||||
{
|
{
|
||||||
|
this->timer_->deleteLater();
|
||||||
|
this->timer_ = nullptr;
|
||||||
this->thread_.quit();
|
this->thread_.quit();
|
||||||
if (!this->thread_.wait(500))
|
if (!this->thread_.wait(500))
|
||||||
{
|
{
|
||||||
@@ -282,18 +285,18 @@ void StreamerModePrivate::settingChanged(StreamerModeSetting value)
|
|||||||
{
|
{
|
||||||
case StreamerModeSetting::Disabled: {
|
case StreamerModeSetting::Disabled: {
|
||||||
this->setEnabled(false);
|
this->setEnabled(false);
|
||||||
this->timer_.stop();
|
this->timer_->stop();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case StreamerModeSetting::Enabled: {
|
case StreamerModeSetting::Enabled: {
|
||||||
this->setEnabled(true);
|
this->setEnabled(true);
|
||||||
this->timer_.stop();
|
this->timer_->stop();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case StreamerModeSetting::DetectStreamingSoftware: {
|
case StreamerModeSetting::DetectStreamingSoftware: {
|
||||||
if (!this->timer_.isActive())
|
if (!this->timer_->isActive())
|
||||||
{
|
{
|
||||||
this->timer_.start(20s);
|
this->timer_->start(20s);
|
||||||
this->check();
|
this->check();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user