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",