You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-15 13:51:40 +00:00
Merge pull request #106454 from KoBeWi/new_cryptic_error_to_your_collection
Fix potential crash when checking unsaved history
This commit is contained in:
@@ -377,16 +377,20 @@ void EditorUndoRedoManager::set_history_as_saved(int p_id) {
|
|||||||
|
|
||||||
void EditorUndoRedoManager::set_history_as_unsaved(int p_id) {
|
void EditorUndoRedoManager::set_history_as_unsaved(int p_id) {
|
||||||
History &history = get_or_create_history(p_id);
|
History &history = get_or_create_history(p_id);
|
||||||
history.saved_version = -1;
|
history.saved_version = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorUndoRedoManager::is_history_unsaved(int p_id) {
|
bool EditorUndoRedoManager::is_history_unsaved(int p_id) {
|
||||||
History &history = get_or_create_history(p_id);
|
History &history = get_or_create_history(p_id);
|
||||||
|
if (history.saved_version == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int version_difference = history.undo_redo->get_version() - history.saved_version;
|
int version_difference = history.undo_redo->get_version() - history.saved_version;
|
||||||
if (version_difference > 0) {
|
if (version_difference > 0) {
|
||||||
List<Action>::Element *E = history.undo_stack.back();
|
List<Action>::Element *E = history.undo_stack.back();
|
||||||
for (int i = 0; i < version_difference; i++) {
|
for (int i = 0; i < version_difference; i++) {
|
||||||
|
ERR_FAIL_NULL_V_MSG(E, false, "Inconsistent undo history.");
|
||||||
if (E->get().mark_unsaved) {
|
if (E->get().mark_unsaved) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -395,6 +399,7 @@ bool EditorUndoRedoManager::is_history_unsaved(int p_id) {
|
|||||||
} else if (version_difference < 0) {
|
} else if (version_difference < 0) {
|
||||||
List<Action>::Element *E = history.redo_stack.back();
|
List<Action>::Element *E = history.redo_stack.back();
|
||||||
for (int i = 0; i > version_difference; i--) {
|
for (int i = 0; i > version_difference; i--) {
|
||||||
|
ERR_FAIL_NULL_V_MSG(E, false, "Inconsistent redo history.");
|
||||||
if (E->get().mark_unsaved) {
|
if (E->get().mark_unsaved) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user