diff options
author | bustico | 2008-05-15 09:03:37 +0000 |
---|---|---|
committer | bustico | 2008-05-15 09:03:37 +0000 |
commit | 83e85f27af6a4c5f7a9c45a8c2e0efcbc413f6a8 (patch) | |
tree | 95e6737af8eba1985b326d754759a8864537fc31 | |
parent | 3708024965cc018303752dc81f4bc80642570c2d (diff) | |
download | ivy-c-83e85f27af6a4c5f7a9c45a8c2e0efcbc413f6a8.zip ivy-c-83e85f27af6a4c5f7a9c45a8c2e0efcbc413f6a8.tar.gz ivy-c-83e85f27af6a4c5f7a9c45a8c2e0efcbc413f6a8.tar.bz2 ivy-c-83e85f27af6a4c5f7a9c45a8c2e0efcbc413f6a8.tar.xz |
fix a broblem in timer.c when a timer is deleted within the timer callback
fix for TRACE compilation problem when compiling with DEBUG
-rw-r--r-- | src/ivydebug.h | 1 | ||||
-rw-r--r-- | src/timer.c | 34 |
2 files changed, 22 insertions, 13 deletions
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 <stdio.h> #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 ); } + } } } |