Add a limit of previously known last element to timer timeout traversal in SceneTree, fixes #15559
This commit is contained in:
parent
7f347cc31a
commit
37c5aa1084
1 changed files with 8 additions and 0 deletions
|
@ -535,10 +535,15 @@ bool SceneTree::idle(float p_time) {
|
|||
|
||||
//go through timers
|
||||
|
||||
List<Ref<SceneTreeTimer> >::Element *L = timers.back(); //last element
|
||||
|
||||
for (List<Ref<SceneTreeTimer> >::Element *E = timers.front(); E;) {
|
||||
|
||||
List<Ref<SceneTreeTimer> >::Element *N = E->next();
|
||||
if (pause && !E->get()->is_pause_mode_process()) {
|
||||
if (E == L) {
|
||||
break; //break on last, so if new timers were added during list traversal, ignore them.
|
||||
}
|
||||
E = N;
|
||||
continue;
|
||||
}
|
||||
|
@ -550,6 +555,9 @@ bool SceneTree::idle(float p_time) {
|
|||
E->get()->emit_signal("timeout");
|
||||
timers.erase(E);
|
||||
}
|
||||
if (E == L) {
|
||||
break; //break on last, so if new timers were added during list traversal, ignore them.
|
||||
}
|
||||
E = N;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue