From a1d841e6f7b9df50e0f90901a79425496bf394ad Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 7 Jul 2016 20:49:43 -0300 Subject: [PATCH] do not allow removal of groups that come from instanced/inherited scene, closes #5505 --- tools/editor/groups_editor.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tools/editor/groups_editor.cpp b/tools/editor/groups_editor.cpp index 898e1e115e4..5b7bc1da78f 100644 --- a/tools/editor/groups_editor.cpp +++ b/tools/editor/groups_editor.cpp @@ -31,7 +31,7 @@ #include "scene/gui/box_container.h" #include "scene/gui/label.h" #include "editor_node.h" - +#include "scene/resources/packed_scene.h" void GroupsEditor::_add_group(const String& p_group) { if (!node) @@ -107,9 +107,35 @@ void GroupsEditor::update_tree() { if (!gi.persistent) continue; + Node *n = node; + bool can_be_deleted=true; + + while(n) { + + Ref ss = (n==EditorNode::get_singleton()->get_edited_scene()) ? n->get_scene_inherited_state() : n->get_scene_instance_state(); + + if (ss.is_valid()) { + + int path = ss->find_node_by_path(n->get_path_to(node)); + if (path!=-1) { + if (ss->is_node_in_group(path,gi.name)) { + can_be_deleted=false; + } + } + } + + n=n->get_owner(); + } + + TreeItem *item=tree->create_item(root); item->set_text(0, gi.name); - item->add_button(0, get_icon("Remove", "EditorIcons"), 0); + if (can_be_deleted) { + item->add_button(0, get_icon("Remove", "EditorIcons"), 0); + } else { + item->set_selectable(0,false); + } + } }