From 63d131967482bc81e1d50e25881e4cace2da4e9e Mon Sep 17 00:00:00 2001 From: xuhuisheng Date: Wed, 5 Nov 2025 10:33:18 +0800 Subject: [PATCH] Fixes crash on queue free scene node in editor Update scene/main/node.cpp Co-authored-by: Lukas Tenbrink --- scene/main/node.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 66defe5ccbb..cee4739abd3 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -279,7 +279,13 @@ void Node::_notification(int p_notification) { ERR_PRINT("Attempted to free a node that is currently added to the SceneTree from a thread. This is not permitted, use queue_free() instead. Node has not been freed."); return; } - +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint() && data.tree && this == data.tree->get_edited_scene_root()) { + cancel_free(); + ERR_PRINT(vformat("Something attempted to free the root Node of a scene (\"%s\"). This is not supported inside the editor, so the Node was not freed.", get_name())); + return; + } +#endif if (data.owner) { _clean_up_owner(); }