Skip to content

Commit

Permalink
Fixed test programs for joystick not exiting on events after first di…
Browse files Browse the repository at this point in the history
…sconnect.

Exit was broken since the main loop extraction needed for Emscripten support
because the former local but now global variables were not reset correctly.
  • Loading branch information
philippwiesemann committed Feb 12, 2015
1 parent 7fd15e7 commit d193283
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/testgamecontroller.c
Expand Up @@ -163,6 +163,10 @@ WatchGameController(SDL_GameController * gamecontroller)
const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1;
char *title = (char *)SDL_malloc(titlelen);
SDL_Window *window = NULL;

retval = SDL_FALSE;
done = SDL_FALSE;

if (title) {
SDL_snprintf(title, titlelen, "%s%s", basetitle, name);
}
Expand Down Expand Up @@ -219,6 +223,10 @@ WatchGameController(SDL_GameController * gamecontroller)
#endif

SDL_DestroyRenderer(screen);
screen = NULL;
background = NULL;
button = NULL;
axis = NULL;
SDL_DestroyWindow(window);
return retval;
}
Expand Down
3 changes: 3 additions & 0 deletions test/testjoystick.c
Expand Up @@ -176,6 +176,8 @@ WatchJoystick(SDL_Joystick * joystick)
{
SDL_Window *window = NULL;
const char *name = NULL;

retval = SDL_FALSE;
done = SDL_FALSE;

/* Create a window to display joystick axis position */
Expand Down Expand Up @@ -217,6 +219,7 @@ WatchJoystick(SDL_Joystick * joystick)
#endif

SDL_DestroyRenderer(screen);
screen = NULL;
SDL_DestroyWindow(window);
return retval;
}
Expand Down

0 comments on commit d193283

Please sign in to comment.