You can get window events after shutting down the window, so don't abort the program if that happens.

This commit is contained in:
Sam Lantinga 2012-12-11 10:50:26 -08:00
parent 5417afcf11
commit a8fab2d5bf

View file

@ -250,11 +250,17 @@ main(int argc, char *argv[])
SDL_JoystickClose(joystick); SDL_JoystickClose(joystick);
} }
if (keepGoing) {
joystick = NULL; joystick = NULL;
if (keepGoing) {
printf("Waiting for attach\n");
}
while (keepGoing) {
SDL_WaitEvent(&event); SDL_WaitEvent(&event);
if ( event.type == SDL_JOYDEVICEADDED ) { if (event.type == SDL_QUIT) {
keepGoing = SDL_FALSE;
} else if (event.type == SDL_JOYDEVICEADDED) {
joystick = SDL_JoystickOpen(atoi(argv[1])); joystick = SDL_JoystickOpen(atoi(argv[1]));
break;
} }
} }
} }