oops null object reference

fix potential null access when the last timer is removed
and changed to iterate through the whole array to support event lists that arent in ascending order (iterating in reverse so in-place array modification via `remove` doesnt mess anything up)
This commit is contained in:
cyn 2024-05-09 16:34:59 -07:00 committed by GitHub
parent 239444123b
commit 1137bf65fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 1 deletions

View File

@ -172,7 +172,18 @@ class SongSequence
private function onUpdate():Void
{
if (!running) return;
while (timers[0].time + startTime > Conductor.instance.songPosition) timers.shift().callback();
var len:Int = timers.length;
for (i in 0...len)
{
var timer:SequenceEvent = timers[len - 1 - i];
if (timer.time + startTime > Conductor.instance.songPosition)
{
timer.callback();
timers.remove(timer);
}
}
if (completed) destroy();
}