From 83e85f27af6a4c5f7a9c45a8c2e0efcbc413f6a8 Mon Sep 17 00:00:00 2001 From: bustico Date: Thu, 15 May 2008 09:03:37 +0000 Subject: fix a broblem in timer.c when a timer is deleted within the timer callback fix for TRACE compilation problem when compiling with DEBUG --- src/ivydebug.h | 1 + src/timer.c | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ivydebug.h b/src/ivydebug.h index ee73f0e..8c43575 100644 --- a/src/ivydebug.h +++ b/src/ivydebug.h @@ -15,6 +15,7 @@ #endif #else #ifdef DEBUG +#include #define TRACE(format, args...) \ fprintf (stderr, format , ## args) diff --git a/src/timer.c b/src/timer.c index 4b07d27..d3ff656 100644 --- a/src/timer.c +++ b/src/timer.c @@ -153,24 +153,32 @@ void TimerScan() int timer_echu = 0; stamp = currentTime(); + /* recherche des timers echu dans la liste */ IVY_LIST_EACH_SAFE( timers , timer, next ) { - if ( timer->when <= stamp ) + if ( timer->when <= stamp ) + { + timer_echu++; + delta = stamp - timer->when; + /* call callback */ + (*timer->callback)( timer, timer->user_data, delta ); + } + } + + IVY_LIST_EACH_SAFE( timers , timer, next ) + { + if ( timer->when <= stamp ) + { + if ( timer->repeat == TIMER_LOOP || --(timer->repeat) ) + { + timer->when = stamp + timer->period; + } + else { - timer_echu++; - delta = stamp - timer->when; - /* call callback */ - (*timer->callback)( timer, timer->user_data, delta ); - if ( timer->repeat == TIMER_LOOP || --(timer->repeat) ) - { - timer->when = stamp + timer->period; - } - else - { - IVY_LIST_REMOVE( timers, timer ); - } + IVY_LIST_REMOVE( timers, timer ); } + } } } -- cgit v1.1