summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-09-20 21:49:46 +0200
committerRémi Verschelde <rverschelde@gmail.com>2017-09-20 21:49:56 +0200
commit4820dfc5707cf767314fa211b19af4e721d7a8df (patch)
tree7b889fac74ac394d24312b7004a22fb1d992a78f /scene/main
parente3617cb18771232876b1318639adb7dc9c5f452b (diff)
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.
Diffstat (limited to 'scene/main')
-rwxr-xr-xscene/main/node.cpp7
1 files changed, 5 insertions, 2 deletions
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 {