On 29-Apr-2002 Claus Hindsgaul wrote:
> By request, I have obtained the following backtraces from valgrind
> (attached) and gdb from a LyX 1.2.0CVS of today with Juergens patch
> applied compiled with --disable-optimization. They were both made doing
> the same thing as in my prior backtraces.
[snip]
> Program received signal SIGSEGV, Segmentation fault.
> Row::par (this=0x18) at lyxrow.h:92
> 92              return par_;
> (gdb) backtrace
>#0  Row::par (this=0x18) at lyxrow.h:92
>#1  0x08132c65 in LyXText::drawInset (this=0x83e0d58, p=@0xbffff000, pos=20) at
>#text.C:495
[snip]

I think I know what's going on. First of all you have 2 insets in one paragraph
(maybe 2 ERT insets). As it is now we don't go back to our original call if we
have a changed row but only set p.row = 0 (I'm pretty sure that if you do:
'up;print *p' you'll see that p.row == 0).

So we probably have to set the p.row to a valid value OR and that is IMO the
better alternative, abort drawing as this is already handled outside so we
surely will reenter and terminate the drawing.

Could you please try the attached patch to the one you already applied?
(both have to be applied to be clear ;)

           Jug

P.S.: In alternative could you send me a minimal .lyx file which shows this
      behaviour with the detailed description what to do to trigger it?

--
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen Vigna        E-Mail:  [EMAIL PROTECTED]
Italienallee 13/N       Tel/Fax: +39-0471-450260 / +39-0471-450253
I-39100 Bozen           Web:     http://www.sad.it/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._

The fact that boys are allowed to exist at all is evidence of a remarkable
Christian forbearance among men.
                -- Ambrose Bierce

Index: src/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.244
diff -u -p -r1.244 text.C
--- src/text.C  24 Apr 2002 15:37:16 -0000      1.244
+++ src/text.C  30 Apr 2002 07:56:30 -0000
@@ -475,13 +475,13 @@ void LyXText::drawNewline(DrawRowParams 
 }
 
 
-void LyXText::drawInset(DrawRowParams & p, pos_type const pos)
+bool LyXText::drawInset(DrawRowParams & p, pos_type const pos)
 {
        Inset * inset = p.row->par()->getInset(pos);
 
        // FIXME: shouldn't happen
        if (!inset) {
-               return;
+               return true;
        }
 
        LyXFont const & font = getFont(p.bv->buffer(), p.row->par(), pos);
@@ -505,7 +505,9 @@ void LyXText::drawInset(DrawRowParams & 
                        need_break_row = p.row;
                }
                setCursor(p.bv, cursor.par(), cursor.pos());
+               return false;
        }
+       return true;
 }
 
 
@@ -630,7 +632,7 @@ void LyXText::drawChars(DrawRowParams & 
 }
 
 
-void LyXText::draw(DrawRowParams & p, pos_type & vpos)
+bool LyXText::draw(DrawRowParams & p, pos_type & vpos)
 {
        pos_type const pos = vis2log(vpos);
        Paragraph * par = p.row->par();
@@ -644,12 +646,13 @@ void LyXText::draw(DrawRowParams & p, po
        if (IsNewlineChar(c)) {
                ++vpos;
                drawNewline(p, pos);
-               return;
+               return true;
        } else if (IsInsetChar(c)) {
-               drawInset(p, pos);
+               if (!drawInset(p, pos))
+                       return false;
                ++vpos;
                drawForeignMark(p, orig_x, orig_font);
-               return;
+               return true;
        }
 
        // usual characters, no insets
@@ -681,6 +684,7 @@ void LyXText::draw(DrawRowParams & p, po
                lyxerr << "No this shouldn't happen!\n";
 #endif
 #endif
+       return true;
 }
 
 
@@ -3662,7 +3666,8 @@ void LyXText::paintRowText(DrawRowParams
                                p.x += p.separator;
                        ++vpos;
                } else {
-                       draw(p, vpos);
+                       if (!draw(p, vpos))
+                               break;
                }
        }
 }
Index: src/lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.110
diff -u -p -r1.110 lyxtext.h
--- src/lyxtext.h       17 Apr 2002 08:34:57 -0000      1.110
+++ src/lyxtext.h       30 Apr 2002 07:56:31 -0000
@@ -649,11 +649,11 @@ private:
        /// draw a mark for foreign language, starting from orig_x
        void drawForeignMark(DrawRowParams & p, float const orig_x, LyXFont const & 
orig_font);
        /// draw an inset
-       void drawInset(DrawRowParams & p, lyx::pos_type const pos);
+       bool drawInset(DrawRowParams & p, lyx::pos_type const pos);
        /// draw new line marker
        void drawNewline(DrawRowParams & p, lyx::pos_type const pos);
        /// draw text
-       void draw(DrawRowParams & p, lyx::pos_type & vpos);
+       bool draw(DrawRowParams & p, lyx::pos_type & vpos);
 
        /// get the next breakpoint in a given paragraph
        lyx::pos_type nextBreakPoint(BufferView *, Row const * row, int width) const;

Reply via email to