Fixed `Scheduler::update` can lead to an infinite loop when the value of `dt` is zero.

This commit is contained in:
WenhaiLin 2015-08-14 15:05:25 +08:00
parent c4af7b8c45
commit d855722c20
1 changed files with 6 additions and 1 deletions

View File

@ -129,12 +129,17 @@ void Timer::update(float dt)
{ {
trigger(interval); trigger(interval);
_elapsed -= interval; _elapsed -= interval;
_timesExecuted += 1;
if (_elapsed <= 0.f)
{
break;
}
if (_runForever) if (_runForever)
{ {
continue; continue;
} }
_timesExecuted += 1;
if (_timesExecuted > _repeat) if (_timesExecuted > _repeat)
{ //unschedule timer { //unschedule timer
cancel(); cancel();