Fixed test programs for joystick not exiting on events after first disconnect.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Thu, 12 Feb 2015 21:40:53 +0100
changeset 9340af5be9462bb4
parent 9339 45c49e8c9416
child 9341 873ef2706bed
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.
test/testgamecontroller.c
test/testjoystick.c
     1.1 --- a/test/testgamecontroller.c	Wed Feb 11 01:48:52 2015 -0500
     1.2 +++ b/test/testgamecontroller.c	Thu Feb 12 21:40:53 2015 +0100
     1.3 @@ -163,6 +163,10 @@
     1.4      const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1;
     1.5      char *title = (char *)SDL_malloc(titlelen);
     1.6      SDL_Window *window = NULL;
     1.7 +
     1.8 +    retval = SDL_FALSE;
     1.9 +    done = SDL_FALSE;
    1.10 +
    1.11      if (title) {
    1.12          SDL_snprintf(title, titlelen, "%s%s", basetitle, name);
    1.13      }
    1.14 @@ -219,6 +223,10 @@
    1.15  #endif
    1.16  
    1.17      SDL_DestroyRenderer(screen);
    1.18 +    screen = NULL;
    1.19 +    background = NULL;
    1.20 +    button = NULL;
    1.21 +    axis = NULL;
    1.22      SDL_DestroyWindow(window);
    1.23      return retval;
    1.24  }
     2.1 --- a/test/testjoystick.c	Wed Feb 11 01:48:52 2015 -0500
     2.2 +++ b/test/testjoystick.c	Thu Feb 12 21:40:53 2015 +0100
     2.3 @@ -176,6 +176,8 @@
     2.4  {
     2.5      SDL_Window *window = NULL;
     2.6      const char *name = NULL;
     2.7 +
     2.8 +    retval = SDL_FALSE;
     2.9      done = SDL_FALSE;
    2.10  
    2.11      /* Create a window to display joystick axis position */
    2.12 @@ -217,6 +219,7 @@
    2.13  #endif
    2.14  
    2.15      SDL_DestroyRenderer(screen);
    2.16 +    screen = NULL;
    2.17      SDL_DestroyWindow(window);
    2.18      return retval;
    2.19  }