mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-10 13:52:38 +02:00
Fix crash of queue_free() when main loop is not SceneTree
(cherry picked from commit 3b08d0e85233a594b016ae27e06b5f21536a6176)
This commit is contained in:
parent
ba39fa8970
commit
095d8c1fef
@ -3095,10 +3095,14 @@ void Node::print_stray_nodes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Node::queue_delete() {
|
void Node::queue_delete() {
|
||||||
|
// There are users which instantiate multiple scene trees for their games.
|
||||||
|
// Use the node's own tree to handle its deletion when relevant.
|
||||||
if (is_inside_tree()) {
|
if (is_inside_tree()) {
|
||||||
get_tree()->queue_delete(this);
|
get_tree()->queue_delete(this);
|
||||||
} else {
|
} else {
|
||||||
SceneTree::get_singleton()->queue_delete(this);
|
SceneTree *tree = SceneTree::get_singleton();
|
||||||
|
ERR_FAIL_NULL_MSG(tree, "Can't queue free a node when no SceneTree is available.");
|
||||||
|
tree->queue_delete(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user