Skip to content

Commit

Permalink
Backport from 1.3 branch: clean up opened joysticks in SDL_JoystickQu…
Browse files Browse the repository at this point in the history
…it().
  • Loading branch information
icculus committed Sep 1, 2011
1 parent 1766848 commit 85c92e3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/joystick/SDL_joystick.c
Expand Up @@ -404,11 +404,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 ) {
Expand Down

0 comments on commit 85c92e3

Please sign in to comment.