diff options
author | Yuri Sizov <yuris@humnom.net> | 2024-01-24 14:08:20 +0100 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2024-01-24 14:08:20 +0100 |
commit | adcfe3d1a0fcb6313c656cbad09fec0ff48ad4a7 (patch) | |
tree | 17242502a5ec87f91c376aa56819234b1055eb44 | |
parent | ea6e20253b1eb4e059a24fb588e55beb48d2e5cb (diff) | |
parent | 2f697926b0aac7fd59fd5bd0e496f0327dd98428 (diff) | |
download | redot-engine-adcfe3d1a0fcb6313c656cbad09fec0ff48ad4a7.tar.gz |
Merge pull request #87252 from ajreckof/Fix-renaming-a-node-to-the-name-of-its-siblings-breaking-NodePath
Fix renaming a node to the name of its siblings breaking NodePath
-rw-r--r-- | editor/gui/scene_tree_editor.cpp | 5 | ||||
-rw-r--r-- | scene/main/node.cpp | 5 | ||||
-rw-r--r-- | scene/main/node.h | 1 |
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 f7d695bf31..704ff3e978 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); |