From 4820dfc5707cf767314fa211b19af4e721d7a8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 20 Sep 2017 21:49:46 +0200 Subject: Let queue_free() work on nodes which are not in the scene tree In practice such nodes could directly be free()'ed, but this little change prevents users from leaking memory by mistake. Closes #9074. --- scene/main/node.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'scene/main') diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 319f123da9..0ab41b40d8 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2572,8 +2572,11 @@ void Node::print_stray_nodes() { void Node::queue_delete() { - ERR_FAIL_COND(!is_inside_tree()); - get_tree()->queue_delete(this); + if (is_inside_tree()) { + get_tree()->queue_delete(this); + } else { + SceneTree::get_singleton()->queue_delete(this); + } } Array Node::_get_children() const { -- cgit v1.2.3