From 3df8217a0220956a3308faa8229d6c4d74bb21de Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 6 Nov 2022 00:15:19 +0100 Subject: [PATCH] SDLController: Do not manually recycle controller instance SDL_GameControllerFromInstanceID does not increase internal ref counter. Fixes a crash when removing an SDL controller that is in use by another profile --- src/input/api/SDL/SDLController.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/input/api/SDL/SDLController.cpp b/src/input/api/SDL/SDLController.cpp index a3e7eece..57971ecc 100644 --- a/src/input/api/SDL/SDLController.cpp +++ b/src/input/api/SDL/SDLController.cpp @@ -58,13 +58,9 @@ bool SDLController::connect() if (m_diid == -1) return false; - m_controller = SDL_GameControllerFromInstanceID(m_diid); + m_controller = SDL_GameControllerOpen(index); if (!m_controller) - { - m_controller = SDL_GameControllerOpen(index); - if (!m_controller) - return false; - } + return false; if (const char* name = SDL_GameControllerName(m_controller)) m_display_name = name;