   [solved] SDL_QUIT triggering by itself.
  Hello everyone. I'm having a peculiar problem. I created a poker game with SDL, and recently if my game is left idling the SDL_QUIT event is triggered, and the game will exit. This would never happen before and it has been a long time since I've worked on this so I'm not sure what I've introduced to cause this. I'm working with Linux and from time to time even X-Windows will crash from this?!I'm just curious to know if anyone else has experineced anything like this. I've included my event loop in hopes that someone might see the issue there. //Poll for eventswhile(SDL_PollEvent(&event)){switch(event.type){case SDL_QUIT:printf("The SDL_QUIT was activated\n");hand=1;gameover=1;break;case SDL_MOUSEBUTTONUP:upButtonCode();break;case SDL_MOUSEMOTION:mouseMotionCode();break;case SDL_KEYDOWN:switch(event.key.keysym.sym){case SDLK_a:printf("This key doesn't do anything\n");break;case SDLK_ESCAPE:printf("Someone hit the Escape Key\n");hand=1;gameover=1;break;default:break;}break;}}Thanks![Edited by - SigmaX on May 15, 2006 9:19:14 AM]
Quote:if my game is left idling the SDL_QUIT event is triggeredHow long does it need to be idle before it exits? Your event loop looks fine, so it smells like a system issue to me. :-/   ;  Like the above poster said above, the event loop looks just fine.  Could be your system maybe??   ;  Yeah it's really odd. It takes about 5 min of being idle before it quits. It's possible it is a system issue. I am using a modified version of X Windows ( I didn't modify it). I'll have to do some more experimenting. Thanks for the replies.   ;  Mabey you have a resource leak. Did you forget to free a SDL_Surface?   ;Quote:Original post by ForeverNoobieMabey you have a resource leak. Did you forget to free a SDL_Surface?Nope, I'm not sure how that would affect it, but I do have all my surfaces freed. Aside from the SDL_Quit event being triggered. Sometimes X will crash giving me a "(explicit kill or server shutdown)";  this might only be a work around solution, but have you considered not including SDL_QUIT in your event switch? for example, including:void main(){int gameover=0;while(gameover==0){//Poll for eventswhile(SDL_PollEvent(&event)){switch(event.type){case SDL_KEYDOWN:switch(event.key.keysym.sym){case SDLK_ESCAPE:gameover=1;break;default:break;}break;}}}SDL_QUIT;}...i dono just a suggestion   ;Quote:Original post by cwyersthis might only be a work around solution, but have you considered not including SDL_QUIT in your event switch? for example, including:*** Source Snippet Removed ***...i dono just a suggestionYeah I guess that could be a solution. If I have an exit on the ESCAPE then there is not need for me to ctrl+c the program closed. I'll give that a shot on Monday when I come back to work. Gotta love a job where you need to learn this stuff. Thanks!   ;  glad to help.   ;  Oh Damn, looks like my problem is a big memory leak. Now I just need to figure out what is causing the problem. Thanks for everyone's suggestions.   