My Allegro 5.09 program does not work correctly after a computer suspend. I suspect this is a problem with my event loop but I may be incorrect. Any suggestions on how to address this issue?
Can you describe the problem? If it seems it's hanging maybe you didn't stop your timers and they built up a ton of events or something.
After a system suspend (I close my laptop monitor), the Allegro program displays the static image that it last displayed but sprites do not update, the mouse is unresponsive etc. In other words, what you indicated makes a lot of sense: the event queue may be built up and cannot flush. Below is my main loop (with comments not present in the actual code) to indicate what is going on. You will also note that I am using AGUI, though disabling AGUI seems to have no effect on the problem.
I guess the questions are: is there anything I can add to flush the queue after a system suspend? And: would updating to a version of Allegro after 5.09 solve this problem?
Thanks
There is nothing in Allegro that will tell you the system has suspended or resumed, so you could try checking for a large jump in time and if that happens flush the event queue?
Is there a chance he'll get a DISPLAY_LOST event?
Only if he's using D3D.
Anyone know how to purge the event buffer so I can test some of these theories out? I will most likely come back to this problem later. It's really more of a minor annoyance and I have more important things to work on. I'm surprised no one else seems to have come across this problem. Thanks.
Flushing the buffer after 10 minutes of inactivity seems to solve the problem. Thanks. Now all I have to do is figure out why some of the bitmaps seem to get corrupted after a suspend.
Are you using D3D? In theory you should only get corrupted bitmaps with D3D + using ALLEGRO_NO_PRESERVE_TEXTURE.