A5 program doesn't work after computer suspend
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?
5 // Process event in AGUI.
11 // Record Time
m_dSimTime = al_get_time();
16 // Force redraw after event is handled.
bRedraw = true;
19 // Update mouse location.
23 // Update scenegraph
26 // Update timed function callback pipe.
27 // C style callback functions are executed based
28 // on timer and then erased.
bMainLoop = false;
40 // Record mouse position.
49 if(1 ==
53 if(2 ==
61 if(1 ==
65 if(2 ==
bRedraw = true;
bRedraw && al_is_event_queue_empty(
bRedraw = false;
89 // Draw scenegraph
92 // Draw gui
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?
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.
Thread #612807. Printed from Allegro.cc
Are you using D3D? In theory you should only get corrupted bitmaps with D3D + using ALLEGRO_NO_PRESERVE_TEXTURE.