summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorkleonc <9283098+kleonc@users.noreply.github.com>2021-10-08 16:37:03 +0200
committerkleonc <9283098+kleonc@users.noreply.github.com>2021-10-08 16:45:55 +0200
commit23dac247895cc92288f7d69c24aab65a0717735c (patch)
treed590d37fc11ef79ca66189fa1416f5c2f6352d4b /scene/main
parent26b3aff01d5b9832ced1fb2fcdd14abeab4ca4b8 (diff)
Delete objects enqueued for deletion during SceneTree destruction
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/scene_tree.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 3d07e4473d..a122241cd0 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -570,7 +570,11 @@ void SceneTree::finalize() {
root = nullptr;
}
- // cleanup timers
+ // In case deletion of some objects was queued when destructing the `root`.
+ // E.g. if `queue_free()` was called for some node outside the tree when handling NOTIFICATION_PREDELETE for some node in the tree.
+ _flush_delete_queue();
+
+ // Cleanup timers.
for (Ref<SceneTreeTimer> &timer : timers) {
timer->release_connections();
}