summaryrefslogtreecommitdiff
path: root/src/timer.c
diff options
context:
space:
mode:
authorbustico2008-05-15 09:03:37 +0000
committerbustico2008-05-15 09:03:37 +0000
commit83e85f27af6a4c5f7a9c45a8c2e0efcbc413f6a8 (patch)
tree95e6737af8eba1985b326d754759a8864537fc31 /src/timer.c
parent3708024965cc018303752dc81f4bc80642570c2d (diff)
downloadivy-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
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c34
1 files changed, 21 insertions, 13 deletions
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 );
}
+ }
}
}