The following patch fixes a crash with cursor-follows-scrollbar. The
important part is in BufferView_pimpl and it ensures that the cursor
points to the buffer inset. The asserts are just extra safeties.

Comments? This is for 1.4.3svn, but it should apply to 1.5.0svn too.

JMarc

Index: src/BufferView_pimpl.C
===================================================================
--- src/BufferView_pimpl.C	(revision 14995)
+++ src/BufferView_pimpl.C	(working copy)
@@ -519,10 +519,12 @@ void BufferView::Pimpl::scrollDocView(in
 
 	switch (st) {
 	case bv_funcs::CUR_ABOVE:
+		cur.reset(buffer_->inset());
 		t.setCursorFromCoordinates(cur, 0, first);
 		cur.clearSelection();
 		break;
 	case bv_funcs::CUR_BELOW:
+		cur.reset(buffer_->inset());
 		t.setCursorFromCoordinates(cur, 0, last);
 		cur.clearSelection();
 		break;
Index: src/text2.C
===================================================================
--- src/text2.C	(revision 14995)
+++ src/text2.C	(working copy)
@@ -695,6 +695,7 @@ void LyXText::setCursor(CursorSlice & cu
 void LyXText::setCursorIntern(LCursor & cur,
 			      pit_type par, pos_type pos, bool setfont, bool boundary)
 {
+	BOOST_ASSERT(this == cur.text());
 	cur.boundary(boundary);
 	setCursor(cur.top(), par, pos);
 	cur.setTargetX();
Index: src/text.C
===================================================================
--- src/text.C	(revision 14995)
+++ src/text.C	(working copy)
@@ -2462,6 +2462,7 @@ pos_type LyXText::x2pos(pit_type pit, in
 // sets cursor only within this LyXText
 bool LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y)
 {
+	BOOST_ASSERT(this == cur.text());
 	pit_type pit = getPitNearY(y);
 	int yy = theCoords.get(this, pit).y_ - pars_[pit].ascent();
 	lyxerr[Debug::DEBUG]

Reply via email to