Skip to content

Commit

Permalink
Merge pull request godotengine#87252 from ajreckof/Fix-renaming-a-nod…
Browse files Browse the repository at this point in the history
…e-to-the-name-of-its-siblings-breaking-NodePath

Fix renaming a node to the name of its siblings breaking NodePath
  • Loading branch information
YuriSizov committed Jan 24, 2024
2 parents ea6e202 + 2f69792 commit adcfe3d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions editor/gui/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions scene/main/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ class Node : public Object {

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

Expand Down

0 comments on commit adcfe3d

Please sign in to comment.