Fix UndoRedo crash when clearing history
This commit is contained in:
parent
d17201afc2
commit
c3baf83e28
|
@ -41,12 +41,16 @@ 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) {
|
||||||
|
if (E->get().ref.is_valid()) {
|
||||||
|
E->get().ref.unref();
|
||||||
|
} else {
|
||||||
Object *obj = ObjectDB::get_instance(E->get().object);
|
Object *obj = ObjectDB::get_instance(E->get().object);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
memdelete(obj);
|
memdelete(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//ERASE do data
|
//ERASE do data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,12 +246,16 @@ 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) {
|
||||||
|
if (E->get().ref.is_valid()) {
|
||||||
|
E->get().ref.unref();
|
||||||
|
} else {
|
||||||
Object *obj = ObjectDB::get_instance(E->get().object);
|
Object *obj = ObjectDB::get_instance(E->get().object);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
memdelete(obj);
|
memdelete(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
actions.remove(0);
|
actions.remove(0);
|
||||||
if (current_action >= 0) {
|
if (current_action >= 0) {
|
||||||
|
|
Loading…
Reference in New Issue