On Tue, Oct 14, 2003 at 10:00:43AM -0500, Fay John F Contr AAC/WMG wrote:
> I was testing the GLUT demos against the current "freeglut" CVS and
> one of them crashed when I closed its window by clicking on the "X" in the
> upper right-hand corner. The problem is ...
> (1) the "glutPostRedisplay" function asserts that a window exists
> (2) the application's idle callback calls "glutPostRedisplay" (we
> can't do anything about that)
> (3) the "glutMainLoopEvent" function calls the idle callback whether
> or not the application is actually idling (in other words, even if there has
> been a mouse or keyboard event).
Um, unless you have a *very* slow computer or are *very* fast at moving your
mouse, your computer *is* idling.
The freeglut docs explicitly say that you will continue to get idle events
after the window closes. (Old GLUT didn't have this problem because old
GLUT just died when you closed any of your windows except under program
control. At least, under X11...)
Maybe I'm missing something, but this seems to be working as-documented, so
I'm not sure where the problem is.
If this is a bug (the exact chain of events isn't clear from what
you've said), then my impression is that there is a *real* bug in
the way that windows are destroyed: When a window is destroyed, we
should clear its display callback flag (and not let it be selected
as "current window"). If I'm understanding you correctly, your
proposed change would only make it harder to produce the same crash,
rather than eliminating it.
> I propose that the fix should be in (3): let the idle callback be a real
> idle callback. The "while" loop in "freeglut_main.c" starting around line
> 1152 used to be an "if" with the idle callback in the "else" block, along
> with timer checks and joystick polls. I suggest that we return the "while"
There is a good reason to make it a while(): Debugging. (The hardest part
If you make it into an if(), it can be much more painful to debug because
you have to make oh-so-many more trips through parts of the event code.
By doing a while(), you only enter glutMainLoopEvent() once for however
many events there are, and just take care of all oustanding business at
Besides, to the extent that this sounds like a bug, I think that there
fix lies in how windows are destroyed, as I said above.
> to an "if", put the idle callback in the "else" block, and move the timer
> checks and joystick polls to outside the "if-else" statements.
> John F. Fay
"I probably don't know what I'm talking about." http://www.olib.org/~rkr/