From 7b835f24f622aa3232182ab8b35485c60b9b7e76 Mon Sep 17 00:00:00 2001 From: Richard Rauch Date: Tue, 2 Dec 2003 21:04:33 +0000 Subject: [PATCH] Ensure that the time-out for sleeping is never negative. git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@375 7f0cb862-5218-0410-a997-914c9d46530a --- src/freeglut_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/freeglut_main.c b/src/freeglut_main.c index bbcb1ab..4936528 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -423,10 +423,12 @@ static int fgHavePendingRedisplays (void) static long fgNextTimer( void ) { long ret = INT_MAX; - SFG_Timer *timer; + SFG_Timer *timer = fgState.Timers.First; - if( (timer = fgState.Timers.First) ) + if( timer ) ret = timer->TriggerTime - fgElapsedTime(); + if( ret < 0 ) + ret = 0; return ret; } @@ -452,7 +454,7 @@ static void fgSleepForEvents( void ) msec = fgNextTimer( ); if( fgHaveJoystick( ) ) msec = MIN( msec, 10 ); - + wait.tv_sec = msec / 1000; wait.tv_usec = (msec % 1000) * 1000; err = select( socket+1, &fdset, NULL, NULL, &wait ); -- 1.7.10.4