Fix a crash on leaving text edit mode without editing text

Fixup for 5b2853bf92
This commit is contained in:
Dmitri Ovodok 2020-02-22 11:18:26 +02:00
parent 52f357df83
commit 9f90b895bf
2 changed files with 8 additions and 0 deletions

View file

@ -76,6 +76,13 @@ void TextBase::endEdit(EditData& ed)
// replace all undo/redo records collected during text editing with
// one property change
if (undo->getCurIdx() == ted->startUndoIdx) {
// No text changes in "undo" part of undo stack,
// hence nothing to merge and filter.
undo->cleanRedoStack(); // prevent text editing commands from remaining in undo stack
return;
}
using Filter = UndoCommand::Filter;
undo->mergeCommands(ted->startUndoIdx);
undo->last()->filterChildren(Filter::TextEdit, this);

View file

@ -207,6 +207,7 @@ class UndoStack {
void reopen();
void mergeCommands(int startIdx);
void cleanRedoStack() { remove(curIdx); }
};
//---------------------------------------------------------