diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-01-17 15:20:48 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2019-01-17 15:26:38 -0300 |
commit | e0336996ce2a593716f4f47ca5102077d397af94 (patch) | |
tree | 8b292a48e9bc8c765435514f2e3e3e8fc212fb67 /editor | |
parent | f958ba5abcd7dfcde226c8780d0c3d1ce4ca336d (diff) |
Add some checks to avoid disaster when making a node the scene root. Fixes #24484
Diffstat (limited to 'editor')
-rw-r--r-- | editor/scene_tree_dock.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index daa7f92dcf..be1c4a36bd 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -563,6 +563,20 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (node == root) return; + //check that from node to root, all owners are right + + if (node->get_owner() != root) { + accept->set_text(TTR("Node must belong to the edited scene to become root.")); + accept->popup_centered_minsize(); + return; + } + + if (node->get_filename() != String()) { + accept->set_text(TTR("Instantiated scenes can't become root")); + accept->popup_centered_minsize(); + return; + } + editor_data->get_undo_redo().create_action("Make node as Root"); editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node); editor_data->get_undo_redo().add_do_method(root->get_parent(), "remove_child", root); |