Skip to content

Commit

Permalink
Fix for intervals not being clearable after one run.
Browse files Browse the repository at this point in the history
[cappuccino#147 state:resolved]

Reviewed by nciagra
  • Loading branch information
Francisco Ryan Tolmasky I committed Nov 25, 2008
1 parent 2ff51a3 commit 2dc5458
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Foundation/CPTimer.j
Expand Up @@ -243,13 +243,13 @@ var _CPTimerBridgeTimer = function(codeOrFunction, aDelay, shouldRepeat, functio
theFunction = nil;

if (typeof codeOrFunction === "string")
theFunction = function() { new Function(codeOrFunction)(); CPTimersForTimeoutIDs[timeoutID] = nil; }
theFunction = function() { new Function(codeOrFunction)(); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; }
else
{
if (!functionArgs)
functionArgs = [];

theFunction = function() { codeOrFunction.apply(window, functionArgs); CPTimersForTimeoutIDs[timeoutID] = nil; }
theFunction = function() { codeOrFunction.apply(window, functionArgs); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; }
}

CPTimersForTimeoutIDs[timeoutID] = [CPTimer scheduledTimerWithTimeInterval:aDelay / 1000 callback:theFunction repeats:shouldRepeat];
Expand All @@ -268,6 +268,8 @@ window.clearTimeout = function(aTimeoutID)

if (timer)
[timer invalidate];

CPTimersForTimeoutIDs[aTimeoutID] = nil;
}

window.setInterval = function(codeOrFunction, aDelay, functionArgs)
Expand Down

0 comments on commit 2dc5458

Please sign in to comment.