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
+16 -1
View File
@@ -136,6 +136,21 @@ NativeMessagingServer::NativeMessagingServer()
{
}
NativeMessagingServer::~NativeMessagingServer()
{
if (!ipc::IpcQueue::remove("chatterino_gui"))
{
qCWarning(chatterinoNativeMessage) << "Failed to remove message queue";
}
this->thread.requestInterruption();
this->thread.quit();
// Most likely, the receiver thread will still wait for a message
if (!this->thread.wait(250))
{
this->thread.terminate();
}
}
void NativeMessagingServer::start()
{
this->thread.start();
@@ -161,7 +176,7 @@ void NativeMessagingServer::ReceiverThread::run()
return;
}
while (true)
while (!this->isInterruptionRequested())
{
auto buf = messageQueue->receive();
if (buf.isEmpty())