summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajreckof <tbonhoure@ymail.Com>2024-01-16 15:16:58 +0100
committerajreckof <tbonhoure@ymail.Com>2024-01-16 15:18:30 +0100
commit2f697926b0aac7fd59fd5bd0e496f0327dd98428 (patch)
treec9311a2fdaf19fe078639e3fde48b5fed9bea0c2
parent04eafd557faa5fbe8f7f2634810a0d2f24f99770 (diff)
downloadredot-engine-2f697926b0aac7fd59fd5bd0e496f0327dd98428.tar.gz
Fix renaming a node to the name of its siblings breaking NodePath
Also fix cases where node name was not visually updated because name was not changed Co-Authored-By: Nông Văn Tình <53887662+nongvantinh@users.noreply.github.com>
-rw-r--r--editor/gui/scene_tree_editor.cpp5
-rw-r--r--scene/main/node.cpp5
-rw-r--r--scene/main/node.h1
3 files changed, 8 insertions, 3 deletions
diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp
index 7a9df26fa7..8e90ec0194 100644
--- a/editor/gui/scene_tree_editor.cpp
+++ b/editor/gui/scene_tree_editor.cpp
@@ -1051,10 +1051,9 @@ void SceneTreeEditor::_rename_node(Node *p_node, const String &p_name) {
}
}
+ new_name = p_node->get_parent()->prevalidate_child_name(p_node, new_name);
if (new_name == p_node->get_name()) {
- if (item->get_text(0).is_empty()) {
- item->set_text(0, new_name);
- }
+ item->set_text(0, new_name);
return;
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index a6b7ca8188..ed03eeb508 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1214,6 +1214,11 @@ String Node::validate_child_name(Node *p_child) {
_generate_serial_child_name(p_child, name);
return name;
}
+
+String Node::prevalidate_child_name(Node *p_child, StringName p_name) {
+ _generate_serial_child_name(p_child, p_name);
+ return p_name;
+}
#endif
String Node::adjust_name_casing(const String &p_name) {
diff --git a/scene/main/node.h b/scene/main/node.h
index 8130c61a34..c82300e6a0 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -614,6 +614,7 @@ public:
#ifdef TOOLS_ENABLED
String validate_child_name(Node *p_child);
+ String prevalidate_child_name(Node *p_child, StringName p_name);
#endif
static String adjust_name_casing(const String &p_name);