Skip to content

Commit

Permalink
Do not change a node unique name to the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
theraot committed Jul 6, 2023
1 parent 4642448 commit b2bef8c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions editor/gui/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,11 +1019,18 @@ void SceneTreeEditor::_renamed() {
}
}

if (n->is_unique_name_in_owner() && get_tree()->get_edited_scene_root()->get_node_or_null("%" + new_name) != nullptr) {
error->set_text(TTR("Another node already uses this unique name in the scene."));
error->popup_centered();
which->set_text(0, n->get_name());
return;
if (n->is_unique_name_in_owner()) {
Node *existing = get_tree()->get_edited_scene_root()->get_node_or_null("%" + new_name);
if (existing == n) {
which->set_text(0, n->get_name());
return;
}
if (existing != nullptr) {
error->set_text(TTR("Another node already uses this unique name in the scene."));
error->popup_centered();
which->set_text(0, n->get_name());
return;
}
}

_rename_node(n, new_name);
Expand Down

0 comments on commit b2bef8c

Please sign in to comment.