summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-11-13 20:11:22 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-11-13 20:11:22 -0300
commit37c5aa108499104dc417d6b983cb64bcf05f35c2 (patch)
tree2fa4c7d531566ebb862257621cbf080cca763d78
parent7f347cc31a121a059e881d4df52add49642dcca3 (diff)
Add a limit of previously known last element to timer timeout traversal in SceneTree, fixes #15559
-rw-r--r--scene/main/scene_tree.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index f7dec77ce4..168cd38ab7 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -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;
}