Fixed test programs for joystick not exiting on events after first disconnect. Exit was broken since the main loop extraction needed for Emscripten support because the former local but now global variables were not reset correctly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c
index 29e0308..414872c 100644
--- a/test/testgamecontroller.c
+++ b/test/testgamecontroller.c
@@ -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);
}
@@ -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;
}
diff --git a/test/testjoystick.c b/test/testjoystick.c
index 3b2b5bf..72f056c 100644
--- a/test/testjoystick.c
+++ b/test/testjoystick.c
@@ -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 */
@@ -217,6 +219,7 @@ WatchJoystick(SDL_Joystick * joystick)
#endif
SDL_DestroyRenderer(screen);
+ screen = NULL;
SDL_DestroyWindow(window);
return retval;
}