From e0596e41c29da021d28bcd2be76699def726f66e Mon Sep 17 00:00:00 2001 From: Ryan Jarvis Date: Tue, 4 Jun 2013 21:02:57 -0400 Subject: [PATCH] modified removeExpiredTimers to not miss any timers due to mutation of the timerList array --- src/Foundation/Timer/TimerManager.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Foundation/Timer/TimerManager.js b/src/Foundation/Timer/TimerManager.js index 5aa46101..2d54159a 100644 --- a/src/Foundation/Timer/TimerManager.js +++ b/src/Foundation/Timer/TimerManager.js @@ -52,9 +52,7 @@ CAAT.Module({ var tl = this.timerList; var i = tl.length - 1; while (i >= 0) { - if (!tl[i].remove) { - tl[i].checkTask(time); - } + tl[i].checkTask(time); i--; } }, @@ -121,12 +119,13 @@ CAAT.Module({ * Removes expired timers. This method must not be called directly. */ removeExpiredTimers:function () { - var i; var tl = this.timerList; - for (i = 0; i < tl.length; i++) { + var i = tl.length - 1; + while (i >= 0) { if (tl[i].remove) { - tl.splice(i, 1); + tl.splice(i,1); } + i--; } } }