This patch fixes the following crash recipe:

How to reproduce:
- Open a (new) LyX document
- Insert -> Math -> Inline Formula
- Toggle emphasis twice
- Undo

The problem was that undo was called with the cursor at the wrong level.

Testing welcome. I will commit tomorrow.

JMarc

Index: src/mathed/math_nestinset.C
===================================================================
--- src/mathed/math_nestinset.C	(revision 16397)
+++ src/mathed/math_nestinset.C	(working copy)
@@ -345,7 +345,7 @@ int MathNestInset::latex(Buffer const &,
 }
 
 
-bool MathNestInset::notifyCursorLeaves(LCursor & cur)
+bool MathNestInset::notifyCursorLeaves(LCursor & /* cur */)
 {
 #ifdef WITH_WARNINGS
 #warning look here
@@ -383,11 +383,12 @@ void MathNestInset::handleFont
 {
 	// this whole function is a hack and won't work for incremental font
 	// changes...
-	recordUndo(cur, Undo::ATOMIC);
 
-	if (cur.inset().asMathInset()->name() == font)
+	if (cur.inset().asMathInset()->name() == font) {
+		recordUndoInset(cur, Undo::ATOMIC);
 		cur.handleFont(font);
-	else {
+	} else {
+		recordUndo(cur, Undo::ATOMIC);
 		cur.handleNest(createMathInset(font));
 		cur.insert(arg);
 	}

Reply via email to