test/threadwin.c
changeset 1151 be9c9c8f6d53
parent 562 cb40b26523a5
child 1659 14717b52abc0
     1.1 --- a/test/threadwin.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/threadwin.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -14,6 +14,13 @@
     1.4  /* Is the cursor visible? */
     1.5  static int visible = 1;
     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  SDL_Surface *LoadIconSurface(char *file, Uint8 **maskp)
    1.15  {
    1.16  	SDL_Surface *icon;
    1.17 @@ -260,9 +267,8 @@
    1.18  	if ( SDL_Init(init_flags) < 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  	/* Set the icon -- this must be done before the first mode set */
    1.27  	icon = LoadIconSurface("icon.bmp", &icon_mask);
    1.28 @@ -277,7 +283,7 @@
    1.29  	if (  screen == NULL ) {
    1.30  		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
    1.31  						video_bpp, SDL_GetError());
    1.32 -		exit(1);
    1.33 +		quit(1);
    1.34  	}
    1.35  	printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ?
    1.36  						"fullscreen" : "windowed");
    1.37 @@ -302,7 +308,7 @@
    1.38  	if ( SDL_LockSurface(screen) < 0 ) {
    1.39  		fprintf(stderr, "Couldn't lock display surface: %s\n",
    1.40  							SDL_GetError());
    1.41 -		exit(2);
    1.42 +		quit(2);
    1.43  	}
    1.44  	buffer = (Uint8 *)screen->pixels;
    1.45  	for ( i=0; i<screen->h; ++i ) {
    1.46 @@ -326,5 +332,6 @@
    1.47  	}
    1.48  	SDL_WaitThread(mouse_thread, NULL);
    1.49  	SDL_WaitThread(keybd_thread, NULL);
    1.50 +	SDL_Quit();
    1.51  	return(0);
    1.52  }