http://bugzilla.lyx.org/show_bug.cgi?id=2155

The attached patch fixes a major bug (undo crash). See the verbose discussion 
on bugzilla for details.

Comments?

Jürgen
Index: undo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v
retrieving revision 1.69
diff -u -r1.69 undo.C
--- undo.C	24 Nov 2005 16:22:39 -0000	1.69
+++ undo.C	31 Dec 2005 14:49:08 -0000
@@ -150,10 +150,14 @@
 	Buffer * buf = bv.buffer();
 	DocIterator cell_dit = undo.cell.asDocIterator(&buf->inset());
 
-	doRecordUndo(Undo::ATOMIC, cell_dit,
-		   undo.from, cell_dit.lastpit() - undo.end, bv.cursor(),
-			 undo.bparams, undo.isFullBuffer,
-		   otherstack);
+	pit_type end = cell_dit.lastpit() - undo.end;
+	// this might happen if DEPM has deleted a paragraph with pit = 0
+	// (see bug 2155)
+	if (end < 0)
+		end = 0;
+
+	doRecordUndo(Undo::ATOMIC, cell_dit, undo.from, end, bv.cursor(),
+		undo.bparams, undo.isFullBuffer, otherstack);
 
 	// This does the actual undo/redo.
 	//lyxerr << "undo, performing: " << undo << std::endl;

Reply via email to