Kornel Benko wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> 
> cvs from today.
> I have tried to make a minimal lyx-example for the undo crash.
> 1.) Select some text inside the enumarated part
> 2.) type any text
> 3.) undo it
> 4.) undo once again -> command not! disabled, -> crash

This is the problem. The cache_par_ cache_pos bussiness is buggy: if you
delete the par it's pointing to, then s*** happends. It's particularly
incompatible with undo...

Ok to remove it?

Alfredo
? PosIterator.C-save
? PosIterator.h-save
? all.diff
? bfs.cpp
? files
? save
? frontends/screen.C-save
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.250
diff -u -p -u -r1.250 lyxtext.h
--- lyxtext.h	29 Oct 2003 10:47:13 -0000	1.250
+++ lyxtext.h	3 Nov 2003 20:36:44 -0000
@@ -459,9 +459,6 @@ private:
 	/// prohibit this as long as there are back pointers...
 	LyXText(LyXText const &);
 
-	// cache for cursorPar()
-	mutable ParagraphList::iterator cache_par_;
-	mutable int cache_pos_;
 };
 
 /// return the default height of a row in pixels, considering font zoom
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.491
diff -u -p -u -r1.491 text.C
--- text.C	29 Oct 2003 12:18:07 -0000	1.491
+++ text.C	3 Nov 2003 20:36:49 -0000
@@ -1592,11 +1592,7 @@ void LyXText::backspace()
 
 ParagraphList::iterator LyXText::cursorPar() const
 {
-	if (cursor.par() != cache_pos_) {
-		cache_pos_ = cursor.par();
-		cache_par_ = getPar(cache_pos_);
-	}
-	return cache_par_;
+	return getPar(cursor.par());
 }
 
 
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.490
diff -u -p -u -r1.490 text2.C
--- text2.C	29 Oct 2003 10:47:14 -0000	1.490
+++ text2.C	3 Nov 2003 20:36:52 -0000
@@ -74,7 +74,6 @@ LyXText::LyXText(BufferView * bv, InsetT
 	: height(0), width(0),
 	  inset_owner(inset), the_locking_inset(0), bv_owner(bv),
 	  in_inset_(ininset), paragraphs_(&paragraphs),
-		cache_pos_(-1)
 {
 }
 
@@ -90,7 +89,6 @@ void LyXText::init(BufferView * bview)
 
 	width = 0;
 	height = 0;
-	cache_pos_ = -1;
 
 	current_font = getFont(beg, 0);
 
Index: undo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v
retrieving revision 1.26
diff -u -p -u -r1.26 undo.C
--- undo.C	3 Nov 2003 17:47:24 -0000	1.26
+++ undo.C	3 Nov 2003 20:36:52 -0000
@@ -184,9 +184,11 @@ bool performUndoOrRedo(BufferView * bv, 
 
 	// set cursor
 	lyxerr <<   "undo, text: " << undo.text
-		<< " inset: " << pit.inset()
-		<< " index: " << undo.index
-		<< std::endl;
+	       << " inset: " << pit.inset()
+	       << " index: " << undo.index
+	       << " par: " << undo.cursor_par
+	       << " pos: " << undo.cursor_pos
+	       << std::endl;
 
 	// set cursor again to force the position to be the right one
 	text->cursor.par(undo.cursor_par);
@@ -200,12 +202,8 @@ bool performUndoOrRedo(BufferView * bv, 
 	// rebreak the entire lyxtext
 	bv->text->fullRebreak();
 
-	InsetOld * inset = pit.inset();
-	if (inset) {
-		// magic needed to cope with inset locking
-		bv->lockInset(dynamic_cast<UpdatableInset *>(inset));
-	}
-
+	pit.lockPath(bv);
+	
 	finishUndo();
 	return true;
 }

Reply via email to