Clean up any opened joysticks during SDL_JoystickQuit().
Otherwise, these leak memory and maybe operating system handles.
This commit is contained in:
parent
8f75030cce
commit
6b4a7b19a4
1 changed files with 13 additions and 0 deletions
|
@ -403,9 +403,22 @@ SDL_JoystickClose(SDL_Joystick * joystick)
|
||||||
void
|
void
|
||||||
SDL_JoystickQuit(void)
|
SDL_JoystickQuit(void)
|
||||||
{
|
{
|
||||||
|
const int numsticks = SDL_numjoysticks;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Stop the event polling */
|
/* Stop the event polling */
|
||||||
SDL_numjoysticks = 0;
|
SDL_numjoysticks = 0;
|
||||||
|
|
||||||
|
SDL_assert( (SDL_joysticks == NULL) == (numsticks == 0) );
|
||||||
|
|
||||||
|
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 */
|
/* Quit the joystick setup */
|
||||||
SDL_SYS_JoystickQuit();
|
SDL_SYS_JoystickQuit();
|
||||||
if (SDL_joysticks) {
|
if (SDL_joysticks) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue