summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-02-22 09:57:23 +0100
committerGitHub <noreply@github.com>2019-02-22 09:57:23 +0100
commit7e69c160a4b7180b9dfe7479da9209ad458bb838 (patch)
tree1d05d079efe035c6e77759de692e77ef92190819
parent726f31e992f544b73d8209eb95cc3d4ee501a0f0 (diff)
parent79f1d8b4fbac564cb55669bbf05034bb9e15ae4a (diff)
Merge pull request #26129 from YeldhamDev/undoredo_merge_all_fix
Fix 'UndoRedo's 'MERGE_ALL' mode repeating instructions when quickly commiting actions
-rw-r--r--core/undo_redo.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index 00894b41d8..40ccd95758 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -63,43 +63,37 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) {
_discard_redo();
// Check if the merge operation is valid
- if (p_mode != MERGE_DISABLE && actions.size() && actions[actions.size() - 1].name == p_name && actions[actions.size() - 1].last_tick + 800 > ticks) {
+ if (p_mode == MERGE_ENDS && actions.size() && actions[actions.size() - 1].name == p_name && actions[actions.size() - 1].last_tick + 800 > ticks) {
current_action = actions.size() - 2;
- if (p_mode == MERGE_ENDS) {
+ // Clear all do ops from last action, and delete all object references
+ List<Operation>::Element *E = actions.write[current_action + 1].do_ops.front();
- // Clear all do ops from last action, and delete all object references
- List<Operation>::Element *E = actions.write[current_action + 1].do_ops.front();
+ while (E) {
- while (E) {
+ if (E->get().type == Operation::TYPE_REFERENCE) {
- if (E->get().type == Operation::TYPE_REFERENCE) {
+ Object *obj = ObjectDB::get_instance(E->get().object);
- Object *obj = ObjectDB::get_instance(E->get().object);
-
- if (obj)
- memdelete(obj);
- }
-
- E = E->next();
- actions.write[current_action + 1].do_ops.pop_front();
+ if (obj)
+ memdelete(obj);
}
+
+ E = E->next();
+ actions.write[current_action + 1].do_ops.pop_front();
}
actions.write[actions.size() - 1].last_tick = ticks;
-
- merge_mode = p_mode;
-
} else {
Action new_action;
new_action.name = p_name;
new_action.last_tick = ticks;
actions.push_back(new_action);
-
- merge_mode = MERGE_DISABLE;
}
+
+ merge_mode = p_mode;
}
action_level++;