Fix UndoRedo crash when clearing history
(cherry picked from commit c3baf83e28
)
This commit is contained in:
parent
49f323410b
commit
329df4e404
1 changed files with 14 additions and 6 deletions
|
@ -41,9 +41,13 @@ void UndoRedo::_discard_redo() {
|
||||||
for (int i = current_action + 1; i < actions.size(); i++) {
|
for (int i = current_action + 1; i < actions.size(); i++) {
|
||||||
for (List<Operation>::Element *E = actions.write[i].do_ops.front(); E; E = E->next()) {
|
for (List<Operation>::Element *E = actions.write[i].do_ops.front(); E; E = E->next()) {
|
||||||
if (E->get().type == Operation::TYPE_REFERENCE) {
|
if (E->get().type == Operation::TYPE_REFERENCE) {
|
||||||
Object *obj = ObjectDB::get_instance(E->get().object);
|
if (E->get().ref.is_valid()) {
|
||||||
if (obj) {
|
E->get().ref.unref();
|
||||||
memdelete(obj);
|
} else {
|
||||||
|
Object *obj = ObjectDB::get_instance(E->get().object);
|
||||||
|
if (obj) {
|
||||||
|
memdelete(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,9 +225,13 @@ void UndoRedo::_pop_history_tail() {
|
||||||
|
|
||||||
for (List<Operation>::Element *E = actions.write[0].undo_ops.front(); E; E = E->next()) {
|
for (List<Operation>::Element *E = actions.write[0].undo_ops.front(); E; E = E->next()) {
|
||||||
if (E->get().type == Operation::TYPE_REFERENCE) {
|
if (E->get().type == Operation::TYPE_REFERENCE) {
|
||||||
Object *obj = ObjectDB::get_instance(E->get().object);
|
if (E->get().ref.is_valid()) {
|
||||||
if (obj) {
|
E->get().ref.unref();
|
||||||
memdelete(obj);
|
} else {
|
||||||
|
Object *obj = ObjectDB::get_instance(E->get().object);
|
||||||
|
if (obj) {
|
||||||
|
memdelete(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue