From 907ba0d8f284576d81da9b53c4e85697c5b9ed8f Mon Sep 17 00:00:00 2001 From: Robbie Cooper Date: Sat, 15 Oct 2022 15:38:19 -0400 Subject: [PATCH] Have the Rename Node action use the targeted Node to determine the current undo/redo context Formerly, we deduced context implicitly, but this failed and always used the global context instead of the context of the scene containing the Node. This happened because the first argument to `add_do_method`, the SceneTreeEditor, is a descendant of Node and outside the current game scene's tree (it's part of the editor instead). This led the code in `EditorUndoRedoManager::get_history_id_for_object` to choose global context. My solution is to explicitly use the renamed Node to deduce our context because it will always be in the current scene in this situation. Fixes #67276 --- editor/scene_tree_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 42801cdaf10..1f02ec45617 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -1016,7 +1016,7 @@ void SceneTreeEditor::_renamed() { emit_signal(SNAME("node_renamed")); } else { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); - undo_redo->create_action(TTR("Rename Node")); + undo_redo->create_action(TTR("Rename Node"), UndoRedo::MERGE_DISABLE, n); emit_signal(SNAME("node_prerename"), n, new_name); undo_redo->add_do_method(this, "_rename_node", n->get_instance_id(), new_name); undo_redo->add_undo_method(this, "_rename_node", n->get_instance_id(), n->get_name());