From dc08fd48cbf734ff0a27efcc3ab6637eb41b15cb Mon Sep 17 00:00:00 2001 From: Robert Yevdokimov <105675984+ryevdokimov@users.noreply.github.com> Date: Tue, 30 Dec 2025 06:09:29 -0500 Subject: [PATCH] Fix crash after calling `EditorUndoRedoManager.clear_history()` and then interacting with history dock entries --- doc/classes/EditorUndoRedoManager.xml | 2 +- editor/editor_undo_redo_manager.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/classes/EditorUndoRedoManager.xml b/doc/classes/EditorUndoRedoManager.xml index ae46a2c0ace..fe5398692bf 100644 --- a/doc/classes/EditorUndoRedoManager.xml +++ b/doc/classes/EditorUndoRedoManager.xml @@ -73,7 +73,7 @@ - Clears the given undo history. You can clear history for a specific scene, global history, or for all scenes at once if [param id] is [constant INVALID_HISTORY]. + Clears the given undo history. You can clear history for a specific scene, global history, or for all histories at once (except [constant REMOTE_HISTORY]) if [param id] is [constant INVALID_HISTORY]. If [param increase_version] is [code]true[/code], the undo history version will be increased, marking it as unsaved. Useful for operations that modify the scene, but don't support undo. [codeblock] var scene_root = EditorInterface.get_edited_scene_root() diff --git a/editor/editor_undo_redo_manager.cpp b/editor/editor_undo_redo_manager.cpp index 17be09819ae..84820c8e2d1 100644 --- a/editor/editor_undo_redo_manager.cpp +++ b/editor/editor_undo_redo_manager.cpp @@ -447,8 +447,13 @@ void EditorUndoRedoManager::clear_history(int p_idx, bool p_increase_version) { return; } - for (const KeyValue &E : history_map) { + for (KeyValue &E : history_map) { + if (E.key == REMOTE_HISTORY) { + continue; + } E.value.undo_redo->clear_history(p_increase_version); + E.value.undo_stack.clear(); + E.value.redo_stack.clear(); set_history_as_saved(E.key); } emit_signal(SNAME("history_changed"));