소스 검색

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
Robbie Cooper 2 년 전
부모
커밋
907ba0d8f2
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      editor/scene_tree_editor.cpp

+ 1 - 1
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());