Jump to content
  • Advertisement
Sign in to follow this  
Miles Lombardi

Strange bug when closing programme (using allegro library)

This topic is 4823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm making a paint programme, for some reason, and I wanted it to query whether the user wanted to save before they left if they had made changes. Now to save it uses the same code as when I press CTRL+S, but for some reason when it's closing (and only when you press the X in the top right hand corner to do this, as if I press ESC in my programme it runs it perfectly well). These are the two functions, shutdown and save. Shutdown:
void shutdown(){
if (changes){
int todo = MessageBox(win_get_window(), "Do you want to save changes before you leave?", "Save", MB_YESNOCANCEL | MB_ICONQUESTION | MB_DEFBUTTON1);
if (todo == IDNO) run = 0;
if (todo == IDYES) { save(); run = 0;}
}
else
run =0;
}
Run is the boolean which the entire programmed is encased it. IE while (run) {//game} Changes is just a boolean that contains if the user has made any changes. This seems to work fine, the place that it freezes at is in the save function. Which if I call in two other ways, works: save()
void save(){
   char path[480];
   sprintf(path, "./");
   int ok = file_select_ex("Save", path, "bmp", 480, 300, 300);
   if (ok){
   save_bitmap(path, image, NULL);
   changes = 0;
   }
}
It freezes at the line file_select_ex(), which is an allegro function, and it's blocking. Now I gueses that when you click the X it doesn't like blocking functions, which is screwed, so how can I fix this (I was going to change to the Win32 one soon anyway).

Share this post


Link to post
Share on other sites
Advertisement
It sounds like file_select_ex is dependent on the parent window being valid. Since the 'x' button was clicked, the window was probably destroyed. You might want to see if there is a way to intercept the window close request and do your save there, before the window is actually closed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!