Open the UG, click on the first footnote -> crash

The problem is that the bv_owner of the text is set on InsetText::dispatch,
but the insetHist check is done before that.

The attached solves it, even if it doesn't seem the right solution. 
bv_owner -> bv() changes were good to find the crash.

Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.454
diff -u -p -u -r1.454 BufferView_pimpl.C
--- BufferView_pimpl.C  10 Nov 2003 09:06:31 -0000      1.454
+++ BufferView_pimpl.C  10 Nov 2003 09:54:55 -0000
@@ -887,6 +887,7 @@ namespace {
                while ((inset_hit = text->checkInsetHit(x, y))) {
                        inset = inset_hit;
                        text = inset_hit->getText(0);
+                       text->init(bv);
                        lyxerr << "Hit inset: " << inset << " at x: " << x
                                << " y: " << y << endl;
                        theTempCursor.push(static_cast<UpdatableInset*>(inset));
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.495
diff -u -p -u -r1.495 text2.C
--- text2.C     10 Nov 2003 09:06:37 -0000      1.495
+++ text2.C     10 Nov 2003 09:54:58 -0000
@@ -74,7 +74,7 @@ LyXText::LyXText(BufferView * bv, InsetT
          ParagraphList & paragraphs)
        : height(0), width(0), inset_owner(inset), bv_owner(bv),
          in_inset_(ininset), paragraphs_(&paragraphs),
-               cache_pos_(-1)
+         cache_pos_(-1)
 {}
 
 
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.171
diff -u -p -u -r1.171 text3.C
--- text3.C     10 Nov 2003 09:06:37 -0000      1.171
+++ text3.C     10 Nov 2003 09:55:00 -0000
@@ -307,7 +307,7 @@ string const freefont2string()
 
 InsetOld * LyXText::checkInsetHit(int & x, int & y)
 {
-       int y_tmp = y + bv_owner->top_y();
+       int y_tmp = y + bv()->top_y();
 
        LyXCursor cur;
        setCursorFromCoordinates(cur, x, y_tmp);
@@ -498,7 +498,7 @@ void LyXText::cursorNext()
        nextRow(cpit, crit);
        LyXCursor cur;
        setCursor(cur, parOffset(cpit), crit->pos(), false);
-       if (cur.y() < bv_owner->top_y() + bv()->workHeight())
+       if (cur.y() < bv()->top_y() + bv()->workHeight())
                cursorDown(true);
        bv()->updateScrollbar();
 }

Reply via email to