From: Ryan C. Gordon Date: Thu, 1 Sep 2011 08:31:01 +0000 (-0400) Subject: Backport from 1.3 branch: clean up opened joysticks in SDL_JoystickQuit(). X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9504f6e73ff54c6f5042971006e55bd8f989905;p=sdl_omap.git Backport from 1.3 branch: clean up opened joysticks in SDL_JoystickQuit(). --- diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 1972d13..d56eab0 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -403,11 +403,24 @@ void SDL_JoystickClose(SDL_Joystick *joystick) void SDL_JoystickQuit(void) { + const int numsticks = SDL_numjoysticks; + int i; + /* Stop the event polling */ SDL_Lock_EventThread(); SDL_numjoysticks = 0; SDL_Unlock_EventThread(); + if (SDL_joysticks != NULL) { + for (i = 0; i < numsticks; i++) { + SDL_Joystick *stick = SDL_joysticks[i]; + if (stick && (stick->ref_count >= 1)) { + stick->ref_count = 1; + SDL_JoystickClose(stick); + } + } + } + /* Quit the joystick setup */ SDL_SYS_JoystickQuit(); if ( SDL_joysticks ) {