Repository: godotengine/godot (language: cpp)

Issue:
Node signal "renamed" is emitted twice for @tool scripts.
### Tested versions

Tested in Godot Engine v4.4.beta2.official.a013481b0

### System information

Godot v4.4.beta2 - Linux Mint 22.1 (Xia) on X11 - X11 display driver, Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Laptop GPU - AMD Ryzen 7 8845HS w/ Radeon 780M Graphics (16 threads)

### Issue description

When using `renamed` signal from [Node](https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-signal-renamed) in `@tool` script it will be emitted twice on single rename operation from Scene dock.

### Steps to reproduce

1. Open project.
2. Find `CustomNode`.
3. Rename node to something else.
4. It should show `RENAMED` message in Output dock twice, but it is expected to show only once.

When project is running there should also be button to change node name. It will trigger this Output message only once, but logic stays the same.

### Minimal reproduction project (MRP)

[issuewithrename.zip](https://github.com/user-attachments/files/18658367/issuewithrename.zip)


Discussion / hints:
Can confirm, also happens in 4.3 and 4.2.2
This is due to this code:
https://github.com/godotengine/godot/blob/0b6a717ac17f1d6bd7963740cf2c2128b36ff7aa/editor/gui/scene_tree_editor.cpp#L1574-L1575

Related to:
* https://github.com/godotengine/godot/issues/77866

Fix patch:
diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp
index d299e8bb4b80..61b67d0f953b 100644
--- a/editor/gui/scene_tree_editor.cpp
+++ b/editor/gui/scene_tree_editor.cpp
@@ -1571,7 +1571,6 @@ void SceneTreeEditor::rename_node(Node *p_node, const String &p_name, TreeItem *
 		undo_redo->add_undo_method(item, "set_metadata", 0, p_node->get_path());
 		undo_redo->add_undo_method(item, "set_text", 0, p_node->get_name());
 
-		p_node->set_name(new_name);
 		undo_redo->add_do_method(p_node, "set_name", new_name);
 		undo_redo->add_do_method(item, "set_metadata", 0, p_node->get_path());
 		undo_redo->add_do_method(item, "set_text", 0, new_name);


Test patch: