From d4f3ec79de455ecf878fd9bdd8a413faf05c43a8 Mon Sep 17 00:00:00 2001 From: rkrolib Date: Wed, 10 Dec 2003 23:59:45 +0000 Subject: [PATCH] Commit of John's change to stop an infinite-loop condition when the only windows left are freeglut menu windows, and correctly calls exit() if we drop out of the main loop without having requested any freeglut extensions to glutMainLoop() handling. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@382 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/freeglut_main.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/freeglut/freeglut/src/freeglut_main.c b/freeglut/freeglut/src/freeglut_main.c index 5fbce0c..4a4d9c6 100644 --- a/freeglut/freeglut/src/freeglut_main.c +++ b/freeglut/freeglut/src/freeglut_main.c @@ -1088,16 +1088,27 @@ void FGAPIENTRY glutMainLoop( void ) fgState.ExecState = GLUT_EXEC_STATE_RUNNING ; while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING ) { - glutMainLoopEvent( ); + SFG_Window *window; - if( fgStructure.Windows.First == NULL ) + glutMainLoopEvent( ); + /* + * Step through the list of windows, seeing if there are any + * that are not menus + */ + for( window = ( SFG_Window * )fgStructure.Windows.First; + window; + window = ( SFG_Window * )window->Node.Next ) + if ( ! ( window->IsMenu ) ) + break; + + if( ! window ) fgState.ExecState = GLUT_EXEC_STATE_STOP; else { if( fgState.IdleCallback ) fgState.IdleCallback( ); - fgSleepForEvents(); + fgSleepForEvents( ); } } @@ -1106,6 +1117,8 @@ void FGAPIENTRY glutMainLoop( void ) * of a freeglut session, so that another glutInit() call can happen */ fgDeinitialize( ); + if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT ) + exit( 0 ); } /*