fix: cleanly exit on shutdown (#5537)

Co-authored-by: Mm2PL <mm2pl+gh@kotmisia.pl>
Co-authored-by: Nerixyz <nerixdev@outlook.de>
This commit is contained in:
pajlada
2024-08-10 14:24:25 +02:00
committed by GitHub
parent daff83dde8
commit 74d65a345d
23 changed files with 134 additions and 65 deletions
+24 -1
View File
@@ -105,6 +105,12 @@ bool isBroadcasterSoftwareActive()
break;
}
if (!p.waitForFinished(1000))
{
qCWarning(chatterinoStreamerMode) << "Force-killing pgrep";
p.kill();
}
return false;
#elif defined(Q_OS_WIN)
if (!IsWindowsVistaOrGreater())
@@ -160,6 +166,8 @@ public:
[[nodiscard]] bool isEnabled() const;
void start();
private:
void settingChanged(StreamerModeSetting value);
void setEnabled(bool enabled);
@@ -194,9 +202,15 @@ bool StreamerMode::isEnabled() const
return this->private_->isEnabled();
}
void StreamerMode::start()
{
this->private_->start();
}
StreamerModePrivate::StreamerModePrivate(StreamerMode *parent)
: parent_(parent)
{
this->thread_.setObjectName("StreamerMode");
this->timer_.moveToThread(&this->thread_);
QObject::connect(&this->timer_, &QTimer::timeout, [this] {
auto timeouts =
@@ -221,13 +235,22 @@ StreamerModePrivate::StreamerModePrivate(StreamerMode *parent)
QObject::connect(&this->thread_, &QThread::started, [this] {
this->settingChanged(getSettings()->enableStreamerMode.getEnum());
});
}
void StreamerModePrivate::start()
{
this->thread_.start();
}
StreamerModePrivate::~StreamerModePrivate()
{
this->thread_.quit();
this->thread_.wait(50);
if (!this->thread_.wait(500))
{
qCWarning(chatterinoStreamerMode)
<< "Failed waiting for thread, terminating it";
this->thread_.terminate();
}
}
bool StreamerModePrivate::isEnabled() const