From 8cea540eba2391e202db23d4fb45486e53b36e09 Mon Sep 17 00:00:00 2001 From: "Alfonso J. Ramos" Date: Sat, 1 Jul 2023 19:29:54 -0500 Subject: [PATCH] Do not change a node unique name to the same name (cherry picked from commit b2bef8c47babbfea3a11143e428a248f59da4eb5) --- editor/gui/scene_tree_editor.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp index d1756df66cb..7b0b8166300 100644 --- a/editor/gui/scene_tree_editor.cpp +++ b/editor/gui/scene_tree_editor.cpp @@ -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);