Juergen Spitzmueller wrote:
> So it seems that in the crash scenario the cursor is entering the inset in
> some illegal way.

No. The problem is that bv_funcs::coordOffset calls cursorPos() for all 
insets. This triggers the assertion in insetcollapsable, because cursorPos() 
should not be called there when the inset is collapsed.

I see two solutions:

1. Don't call cursorPos() from coordOffset when the inset is not 
HIGHLY_EDITABLE (which is also the case when collapsables are collapsed). 
See attached patch #1.

2. replace the assert by something like
        if (status() == Collapsed)
                return;
see patch #2.
(but I'm sure Alfredo implemented the assert for some reason).

Both approaches fix the crash, but auto-open a collapsable if the position 
inside matches (I'm sure this can be suppressed somehow).

Comments?

Jürgen
Index: bufferview_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.C,v
retrieving revision 1.155
diff -u -r1.155 bufferview_funcs.C
--- bufferview_funcs.C	16 Jul 2005 00:04:53 -0000	1.155
+++ bufferview_funcs.C	7 Nov 2005 08:19:48 -0000
@@ -163,7 +163,8 @@
 		CursorSlice const & sl = dit[i];
 		int xx = 0;
 		int yy = 0;
-		sl.inset().cursorPos(sl, boundary && ((i+1) == dit.depth()), xx, yy);
+		if (sl.inset().editable() == InsetBase::HIGHLY_EDITABLE)
+			sl.inset().cursorPos(sl, boundary && ((i+1) == dit.depth()), xx, yy);
 		x += xx;
 		y += yy;
 		//lyxerr << "LCursor::getPos, i: "
Index: insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.280
diff -u -r1.280 insetcollapsable.C
--- insetcollapsable.C	24 Oct 2005 09:42:20 -0000	1.280
+++ insetcollapsable.C	7 Nov 2005 08:37:09 -0000
@@ -204,8 +204,10 @@
 void InsetCollapsable::cursorPos
 	(CursorSlice const & sl, bool boundary, int & x, int & y) const
 {
-	BOOST_ASSERT(status() != Collapsed);
-	
+	//BOOST_ASSERT(status() != Collapsed);
+	if (status() == Collapsed)
+		return;
+
 	InsetText::cursorPos(sl, boundary, x, y);
 	
 	if (status() == Open) {

Reply via email to