test/testwm.c
changeset 1151 be9c9c8f6d53
parent 826 3eddf51b649b
child 1284 08e3393e9ffb
     1.1 --- a/test/testwm.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/testwm.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -13,6 +13,13 @@
     1.4  static Uint8  video_bpp;
     1.5  static Uint32 video_flags;
     1.6  
     1.7 +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
     1.8 +static void quit(int rc)
     1.9 +{
    1.10 +	SDL_Quit();
    1.11 +	exit(rc);
    1.12 +}
    1.13 +
    1.14  int SetVideoMode(int w, int h)
    1.15  {
    1.16  	SDL_Surface *screen;
    1.17 @@ -264,9 +271,8 @@
    1.18  	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    1.19  		fprintf(stderr,
    1.20  			"Couldn't initialize SDL: %s\n", SDL_GetError());
    1.21 -		exit(1);
    1.22 +		return(1);
    1.23  	}
    1.24 -	atexit(SDL_Quit);
    1.25  
    1.26  	/* Check command line arguments */
    1.27  	w = 640;
    1.28 @@ -333,7 +339,7 @@
    1.29  
    1.30  	/* Initialize the display */
    1.31  	if ( SetVideoMode(w, h) < 0 ) {
    1.32 -		return(1);
    1.33 +		quit(1);
    1.34  	}
    1.35  
    1.36  	/* Set an event filter that discards everything but QUIT */
    1.37 @@ -355,7 +361,7 @@
    1.38  				/* Fall through to the quit handler */
    1.39  			case SDL_QUIT:
    1.40  				printf("Bye bye..\n");
    1.41 -				return(0);
    1.42 +				quit(0);
    1.43  			default:
    1.44  				/* This should never happen */
    1.45  				printf("Warning: Event %d wasn't filtered\n",
    1.46 @@ -364,5 +370,6 @@
    1.47  		}
    1.48  	}
    1.49  	printf("SDL_WaitEvent() error: %s\n", SDL_GetError());
    1.50 +	SDL_Quit();
    1.51  	return(255);
    1.52  }