Re: Text colour segfault


Subject: Re: Text colour segfault
From: Joaquín Cuenca Abela (cuenca@ie2.u-psud.fr)
Date: Thu Apr 06 2000 - 15:48:59 CDT


James Montgomerie wrote:
>
> "Matthew Kirkwood" wrote:
>
> > Subject: Re: Text colour segfault
> >
> > On Thu, 6 Apr 2000, James Montgomerie wrote:
> >
> > > I was just about to post about this! It's hapening to me too, on
> a
> > > plain-old RedHat 6.1 install. It happens to GTK AbiWord too.
> >
> > You should probably tell the list this, especially that it happens
> > with the plain Gtk+ version.
>
> I thought I had - I was wondering why it was taking so long to appear!

I have been tracking this bug...
It seems to be a bug in the setFont function (gr_UnixGraphics.cc
module). Exactly here:

        // want to only call this once, if possible, on a new font
        GdkFont * newGdkFont = pUFont->getGdkFont();
        UT_ASSERT(newGdkFont);
        
        if (m_pFont && gdk_font_equal (newGdkFont, m_pFont->getGdkFont()))
        {
                return;
        }
        
        m_pFont = pUFont;

It doesn't act like the old version (the version with raw X calls):

        if (m_pFont)

{
                XFontStruct* pCurFont = (XFontStruct
*)((GdkFontPrivate*)m_pFont->getGdkFont())->xfont;
                XFontStruct* pNewFont = (XFontStruct
*)((GdkFontPrivate*)newGdkFont)->xfont;
                        
                UT_ASSERT(pCurFont && pNewFont);
                        
                if (!pCurFont->fid == pNewFont->fid)
                {
                        return;
                }
                

}
        
        m_pFont = pUFont;

But the real problem is that I don't understand what is the meaning of
the original version...
I think that Shaw wanted to save the copy of a m_pFont if the new font
was really the same one, but I don't understand the `!' in the if (...).

I think that it was a bug in the original code... the `!' makes all the
if (...) block useless, because it cann't reach the "return" line, and
so I think the solution to the bug is to erase all the if (...) block,
so we have to change:

        if (m_pFont && gdk_font_equal (newGdkFont, m_pFont->getGdkFont()))
        {
                return;
        }
        
        m_pFont = pUFont;

by only:

        m_pFont = pUFont;

Do you agree?

P.S.: Thank you to Matthew Kirkwood for this great bug report. I just
cann't believe that nobody has found this bug before...
P.S.2: If everybody agree, I will commit the one line patch to cvs ASAP

--
Joaquín Cuenca Abela
e-mail: cuenca@ie2.u-psud.fr



This archive was generated by hypermail 2b25 : Thu Apr 06 2000 - 15:49:30 CDT