Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if history exists before discarding #87980

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion editor/editor_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ void EditorData::remove_scene(int p_idx) {
EditorNode::get_singleton()->emit_signal("scene_closed", edited_scene[p_idx].path);
}

undo_redo_manager->discard_history(edited_scene[p_idx].history_id);
if (undo_redo_manager->has_history(edited_scene[p_idx].history_id)) { // Might not exist if scene failed to load.
undo_redo_manager->discard_history(edited_scene[p_idx].history_id);
}
edited_scene.remove_at(p_idx);
}

Expand Down
4 changes: 4 additions & 0 deletions editor/editor_undo_redo_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ bool EditorUndoRedoManager::has_redo() {
return false;
}

bool EditorUndoRedoManager::has_history(int p_idx) const {
return history_map.has(p_idx);
}

void EditorUndoRedoManager::clear_history(bool p_increase_version, int p_idx) {
if (p_idx != INVALID_HISTORY) {
History &history = get_or_create_history(p_idx);
Expand Down
1 change: 1 addition & 0 deletions editor/editor_undo_redo_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class EditorUndoRedoManager : public Object {
bool is_history_unsaved(int p_idx);
bool has_undo();
bool has_redo();
bool has_history(int p_idx) const;

String get_current_action_name();
int get_current_action_history_id();
Expand Down
Loading