commit ac271336ddc77c25634d8f6f5842b61e71c0e439
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri May 22 18:16:23 2015 +0200
Avoid crash with undo in a closed collapsable inset
The recipe for reproducing this crash is to do a search and replace
that changes a string present in a collapsed inset, and then undo.
This is a followup to d5eeabcf, which used editable() instead of
isActive(); this commit was amended at a6bc4a2a, since editable() is
not set properly in mathed.
Truth is, editable() is not the right property to test against, since
it is false for a collapsed inset, which does not prevent a cursor
from pointing inside. Therefore sanitize should not change the cursor
in this case.
Hopefuly, this is the last word on the subject. Alternative would be
to drop this if()-clause completely.
diff --git a/src/DocIterator.cpp b/src/DocIterator.cpp
index db52912..01d0639 100644
--- a/src/DocIterator.cpp
+++ b/src/DocIterator.cpp
@@ -555,8 +555,7 @@ void DocIterator::sanitize()
fixIfBroken();
break;
}
- if ((inset->inMathed() && !inset->isActive())
- || (!inset->inMathed() && !inset->editable())) {
+ if (!inset->isActive()) {
LYXERR0("Inset found on cursor stack is not active.");
fixIfBroken();
break;
diff --git a/src/Undo.cpp b/src/Undo.cpp
index 31eaec3..7fdd8fa 100644
--- a/src/Undo.cpp
+++ b/src/Undo.cpp
@@ -396,6 +396,7 @@ void Undo::Private::doTextUndoOrRedo(CursorData & cur,
UndoElementStack & stack,
// We will store in otherstack the part of the document under 'undo'
DocIterator cell_dit = undo.cell.asDocIterator(&buffer_);
+ LATTEST(undo.end <= cell_dit.lastpit());
doRecordUndo(ATOMIC_UNDO, cell_dit,
undo.from, cell_dit.lastpit() - undo.end, undo.cur_after,
undo.isFullBuffer, otherstack);