You can get window events after shutting down the window, so don't abort the program if that happens.
authorSam Lantinga <slouken@libsdl.org>
Tue, 11 Dec 2012 10:50:26 -0800
changeset 6736 03dd4a1d06e9
parent 6735 486800c3f44c
child 6737 63ba9e5b1272
You can get window events after shutting down the window, so don't abort the program if that happens.
test/testjoystick.c
--- a/test/testjoystick.c	Tue Dec 11 10:49:54 2012 -0800
+++ b/test/testjoystick.c	Tue Dec 11 10:50:26 2012 -0800
@@ -250,11 +250,17 @@
                 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;
                 }
             }
         }