Add a limit of previously known last element to timer timeout traversal in SceneTree, fixes #15559

This commit is contained in:
Juan Linietsky 2018-11-13 20:11:22 -03:00
parent 7f347cc31a
commit 37c5aa1084

View file

@ -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;
}