From de52fa2f84008a22cf2811de6dfd6c6ecabc3cfb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 11 Dec 2012 10:50:26 -0800 Subject: [PATCH] You can get window events after shutting down the window, so don't abort the program if that happens. --- test/testjoystick.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/testjoystick.c b/test/testjoystick.c index 6f53321e7..af99fd53b 100644 --- a/test/testjoystick.c +++ b/test/testjoystick.c @@ -250,11 +250,17 @@ main(int argc, char *argv[]) SDL_JoystickClose(joystick); } + joystick = NULL; if (keepGoing) { - joystick = NULL; - SDL_WaitEvent( &event ); - if ( event.type == SDL_JOYDEVICEADDED ) { + printf("Waiting for attach\n"); + } + while (keepGoing) { + SDL_WaitEvent(&event); + if (event.type == SDL_QUIT) { + keepGoing = SDL_FALSE; + } else if (event.type == SDL_JOYDEVICEADDED) { joystick = SDL_JoystickOpen(atoi(argv[1])); + break; } } }