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>
This commit is contained in:
ajreckof 2024-01-16 15:16:58 +01:00
parent 04eafd557f
commit 2f697926b0
3 changed files with 8 additions and 3 deletions

View File

@ -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;
}

View File

@ -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) {

View File

@ -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);