Program won't shut down

Hi everybody,
I am working on a small Tile-Engine with SDL. Everything works quite fine exept of the termination of the application. I know that my program gets the SDL_QUIT event and tries to shut down the application, but it won’t. The main graphics-window closes down as it should, but the process is still running in the background and I have to quit it via Task-Manager.

Here the most important parts out of main:

SDL_Surface *screen;
SDL_TimerID timerid;

//Initialize the SDL subsystems
if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 )
{
printf(SDL_GetError());
return 0;
}
atexit(SDL_Quit);
printf(“SDL initialized successfully\n”);

screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, PDEPTH, \
SDL_HWSURFACE|SDL_DOUBLEBUF);
if ( screen == NULL )
{
printf(“Couldn’t initialize SDL: %s\n”, SDL_GetError());
return FALSE;
}
printf(“SDL video-mode successfully initialized\n”);

// Set the timer to 30 ms
timerid = SDL_AddTimer(30, UpdateAndDraw, &data);

//Run
while(data.done == FALSE)
{
//…
}//*/

// quit the timer
SDL_RemoveTimer(timerid);

SDL_FreeSurface(screen);
screen = NULL;

// shutdown the game, free all the data like textures
Shutdown();

return 1;
}

I know that data.done gets set when I press Escape as it should, so the error should be somewhere below the loop. I also tried to run the program without initializing the timer and without the loop, but no success, still the same problem as before.
Hope you can help me, I don’t want to have a program which is not even able to quit correctly.

If it helps:
My OS: Windows
Compiler is DevC++ 4.9.9.2
SDL-Libs 1.2.4 are used—
Thanks
Jan Brinker

Hope you can help me, I don’t want to have a program which is not even
able to quit correctly.

Call SDL_Quit() before the “return 1”.

–ryan.

Well, it already should call it because I call atexit(SDL_Quit); in main. But if I add a SDL_Quit(); before the “return 1”, I still get the same error. I also tried it with only 1 call (I commented out that “atexit(SDL_Quit);” and put the “SDL_Quit();” before the return), and with 2 calls (left that “atexit(SDL_Quit);” in my code and added “SDL_Quit()”), nothing worked.
-----Urspr?ngliche Mitteilung-----
Verschickt: Sa., 20.Jan.2007, 18:04
Thema: Re: [SDL] Program won’t shut down

Hope you can help me, I don’t want to have a program which is not even
able to quit correctly.

Call SDL_Quit() before the “return 1”.

–ryan.Von: icculus at icculus.org
An: sdl at libsdl.org


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

El S?bado, 20 de Enero de 2007 18:29, janoskarbrinker at aol.com escribi?:

?Well, it already should call it because I call atexit(SDL_Quit); in main.
But if I add a SDL_Quit(); before the “return 1”, I still get the same
error. I also tried it with only 1 call (I commented out that
"atexit(SDL_Quit);" and put the “SDL_Quit();” before the return), and with
2 calls (left that “atexit(SDL_Quit);” in my code and added “SDL_Quit()”),
nothing worked.

Are you running the program from Dev-C++ or directly from the executable?
Could be any difference?

SDL_FreeSurface(screen);
screen = NULL;

The surface returned by SDL_SetVideoMode() is freed be SDL_Quit() and
should not be freed by the caller.

Hope that helpsAm Samstag, dem 20. Jan 2007 schrieb janoskarbrinker at aol.com:


AKFoerster

I tried both things. Nothing worked, neither starting the .exe from the Explorer, nor commenting out the FreeSurface.—
Jan Brinker

El Lunes, 22 de Enero de 2007 19:22, janoskarbrinker escribi?:

I tried both things. Nothing worked, neither starting the .exe from the
Explorer, nor commenting out the FreeSurface.

Could you remove the tile engine part and make a little example file for us to
compile and test?