From aad0090d97179c1ed6dae3dd15d8a851d3199ebe Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 12 Nov 2026 20:22:02 -0600 Subject: [PATCH] Invoke QCoreApplication::quit() on the main thread This is required to safely synchronize with the main loop. --- app/main.cpp | 8 ++++++-- app/streaming/session.cpp | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 6629a752..7250bd76 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -381,8 +381,12 @@ int SDLCALL signalHandlerThread(void* data) _Exit(1); } - // If we're not streaming, we'll close the whole app - QCoreApplication::instance()->quit(); + // If we're not streaming, we'll close the whole app on the main thread + if (QCoreApplication* app = QCoreApplication::instance()) { + QMetaObject::invokeMethod(app, []() { + QCoreApplication::quit(); + }, Qt::QueuedConnection); + } requestedQuit = true; } break; diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 3898c00f..75d30a1d 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -1307,7 +1307,11 @@ private: // Exit the entire program if requested if (m_Session->m_ShouldExit) { - QCoreApplication::instance()->quit(); + if (QCoreApplication* app = QCoreApplication::instance()) { + QMetaObject::invokeMethod(app, []() { + QCoreApplication::quit(); + }, Qt::QueuedConnection); + } } }