From 06407be5a72d2983755372708f07d1af712a00ef Mon Sep 17 00:00:00 2001 From: rainmakerv3 <30595646+rainmakerv3@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:50:39 +0800 Subject: [PATCH] Properly exit event loop thread on exit --- src/qt_gui/control_settings.cpp | 10 ++++++++-- src/qt_gui/control_settings.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/qt_gui/control_settings.cpp b/src/qt_gui/control_settings.cpp index fbeedc802..319daecdd 100644 --- a/src/qt_gui/control_settings.cpp +++ b/src/qt_gui/control_settings.cpp @@ -124,8 +124,9 @@ ControlSettings::ControlSettings(std::shared_ptr game_info_get, b QObject::connect(RemapWrapper, &SdlEventWrapper::Wrapper::SDLEvent, this, &ControlSettings::processSDLEvents); - if (!GameRunning) - QFuture future = QtConcurrent::run(&ControlSettings::pollSDLEvents, this); + if (!GameRunning) { + Polling = QtConcurrent::run(&ControlSettings::pollSDLEvents, this); + } } void ControlSettings::SaveControllerConfig(bool CloseOnSave) { @@ -926,6 +927,11 @@ void ControlSettings::Cleanup() { SDL_CloseGamepad(gamepad); if (!GameRunning) { + SDL_Event quitLoop{}; + quitLoop.type = SDL_EVENT_QUIT; + SDL_PushEvent(&quitLoop); + Polling.waitForFinished(); + SDL_QuitSubSystem(SDL_INIT_GAMEPAD); SDL_QuitSubSystem(SDL_INIT_EVENTS); SDL_Quit(); diff --git a/src/qt_gui/control_settings.h b/src/qt_gui/control_settings.h index 00ac202fd..76d16b84e 100644 --- a/src/qt_gui/control_settings.h +++ b/src/qt_gui/control_settings.h @@ -63,6 +63,7 @@ private: QPushButton* MappingButton; SDL_Gamepad* gamepad = nullptr; SdlEventWrapper::Wrapper* RemapWrapper; + QFuture Polling; const std::vector ControllerInputs = { "cross", "circle", "square", "triangle", "l1",