Merge pull request #108684 from simpkins/unique_name

Fix releasing the old unique name when renaming a Node
This commit is contained in:
Thaddeus Crews
2025-07-17 10:34:44 -05:00

View File

@ -1416,10 +1416,15 @@ void Node::_set_name_nocheck(const StringName &p_name) {
void Node::set_name(const StringName &p_name) {
ERR_FAIL_COND_MSG(data.tree && !Thread::is_main_thread(), "Changing the name to nodes inside the SceneTree is only allowed from the main thread. Use `set_name.call_deferred(new_name)`.");
ERR_FAIL_COND(p_name.is_empty());
const StringName old_name = data.name;
if (data.unique_name_in_owner && data.owner) {
_release_unique_name_in_owner();
}
{
const String input_name_str = String(p_name);
ERR_FAIL_COND(input_name_str.is_empty());
const String validated_node_name_string = input_name_str.validate_node_name();
if (input_name_str == validated_node_name_string) {
data.name = p_name;
@ -1428,10 +1433,6 @@ void Node::set_name(const StringName &p_name) {
}
}
if (data.unique_name_in_owner && data.owner) {
_release_unique_name_in_owner();
}
if (data.parent) {
data.parent->_validate_child_name(this, true);
bool success = data.parent->data.children.replace_key(old_name, data.name);