From 5f46bca8240bb440a1581cd6380f624df010aad3 Mon Sep 17 00:00:00 2001 From: Rindbee Date: Thu, 29 Jun 2023 15:38:19 +0800 Subject: [PATCH] Fix history mismatch Set the properties of the resource's proxy instead of setting the resource's properties directly. (For action "Set ...") Update the path of the edited scene when saving the scene. (For action "Add atlas source") (cherry picked from commit 28db5e76495bab5f0cb3fa4a4b7d4769d25c9962) --- editor/editor_node.cpp | 3 +++ editor/plugins/tiles/tile_set_atlas_source_editor.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 5b3a29ac2cf..4e3b3fcc904 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1982,6 +1982,9 @@ void EditorNode::_dialog_action(String p_file) { if (scene_idx != -1) { _discard_changes(); + } else { + // Update the path of the edited scene to ensure later do/undo action history matches. + editor_data.set_scene_path(editor_data.get_edited_scene(), p_file); } } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 6ec45b1f956..7a337a9f2b2 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -2156,7 +2156,7 @@ void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo Ref atlas_source = atlas_source_proxy->get_edited(); ERR_FAIL_COND(!atlas_source.is_valid()); - UndoRedo *internal_undo_redo = undo_redo_man->get_history_for_object(atlas_source.ptr()).undo_redo; + UndoRedo *internal_undo_redo = undo_redo_man->get_history_for_object(atlas_source_proxy).undo_redo; internal_undo_redo->start_force_keep_in_merge_ends(); PackedVector2Array arr; @@ -2180,7 +2180,7 @@ void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo String prefix = vformat("%d:%d/", coords.x, coords.y); for (PropertyInfo pi : properties) { if (pi.name.begins_with(prefix)) { - ADD_UNDO(atlas_source.ptr(), pi.name); + ADD_UNDO(atlas_source_proxy, pi.name); } } }