>>>>> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes:

Juergen> http://bugzilla.lyx.org/show_bug.cgi?id=2202 Jean-Marc,

Juergen> I found that the attached patch fixes the described crash for
Juergen> me. The cases described in bug 2155 still work. However, I'm
Juergen> not really sure I got the logic. Does this make sense to you?

I was about to post almost the same patch :)

I think yours is just as good. You should probably add a 'using
std::max' somewhere, though.

JMarc

Index: src/text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.639
diff -u -p -r1.639 text2.C
--- src/text2.C	28 Jan 2006 12:39:22 -0000	1.639
+++ src/text2.C	30 Jan 2006 15:05:07 -0000
@@ -1252,9 +1252,13 @@ bool LyXText::deleteEmptyParagraphMechan
 		return false;
 
 	if (oldpar.empty() || (oldpar.size() == 1 && oldpar.isLineSeparator(0))) {
+		// first the undo
+		if (old.pit())
+			recordUndo(old, Undo::ATOMIC, old.pit() - 1, old.pit());
+		else
+			recordUndo(old, Undo::ATOMIC, 0, 1);
+
 		// Delete old par.
-		recordUndo(old, Undo::ATOMIC, 
-			   old.pit(), min(old.pit() + 1, old.lastpit()));
 		ParagraphList & plist = old.text()->paragraphs();
 		plist.erase(plist.begin() + old.pit());
 

Juergen> Jürgen

Juergen> Index: src/text2.C
Juergen> ===================================================================
Juergen> RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
Juergen> retrieving revision 1.638 diff -p -u -r1.638 text2.C ---
Juergen> src/text2.C 23 Jan 2006 10:25:41 -0000 1.638 +++ src/text2.C
Juergen> 30 Jan 2006 14:50:41 -0000 @@ -1248,8 +1248,9 @@ bool
Juergen> LyXText::deleteEmptyParagraphMechan
 
Juergen>        if (oldpar.empty() || (oldpar.size() == 1 &&
Juergen> oldpar.isLineSeparator(0))) { // Delete old par. -
Juergen> recordUndo(old, Undo::ATOMIC, - old.pit(), min(old.pit() + 1,
Juergen> old.lastpit())); + recordUndo(old, Undo::ATOMIC, +
Juergen> std::max(old.pit() - 1, 0), + min(old.pit() + 1,
Juergen> old.lastpit())); ParagraphList & plist =
Juergen> old.text()->paragraphs(); plist.erase(plist.begin() +
Juergen> old.pit());
 

Reply via email to