MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / set_name

Method set_name

scene/main/node.cpp:1450–1486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1448}
1449
1450void Node::set_name(const StringName &p_name) {
1451 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)`.");
1452 ERR_FAIL_COND(p_name.is_empty());
1453
1454 const StringName old_name = data.name;
1455 if (data.unique_name_in_owner && data.owner) {
1456 _release_unique_name_in_owner();
1457 }
1458
1459 {
1460 const String input_name_str = String(p_name);
1461 const String validated_node_name_string = input_name_str.validate_node_name();
1462 if (input_name_str == validated_node_name_string) {
1463 data.name = p_name;
1464 } else {
1465 data.name = StringName(validated_node_name_string);
1466 }
1467 }
1468
1469 if (data.parent) {
1470 data.parent->_validate_child_name(this, true);
1471 bool success = data.parent->data.children.replace_key(old_name, data.name);
1472 ERR_FAIL_COND_MSG(!success, "Renaming child in hashtable failed, this is a bug.");
1473 }
1474
1475 if (data.unique_name_in_owner && data.owner) {
1476 _acquire_unique_name_in_owner();
1477 }
1478
1479 propagate_notification(NOTIFICATION_PATH_RENAMED);
1480
1481 if (is_inside_tree()) {
1482 emit_signal(SNAME("renamed"));
1483 data.tree->node_renamed(this);
1484 data.tree->tree_changed();
1485 }
1486}
1487
1488String Node::get_description() const {
1489 String description;

Callers 15

_create_node_funcMethod · 0.45
_instance_node_funcMethod · 0.45
_duplicate_node_funcMethod · 0.45
_reparent_node_funcMethod · 0.45
add_layerMethod · 0.45
_setMethod · 0.45
TileMapMethod · 0.45
instantiateMethod · 0.45
get_meshMethod · 0.45

Calls 8

validate_node_nameMethod · 0.80
_validate_child_nameMethod · 0.80
node_renamedMethod · 0.80
tree_changedMethod · 0.80
StringClass · 0.50
StringNameClass · 0.50
is_emptyMethod · 0.45
replace_keyMethod · 0.45

Tested by

no test coverage detected