On Sun, Nov 12, 2000 at 05:13:54AM -0600, Sam TH wrote:
> On Sun, Nov 12, 2000 at 02:05:27AM -0800, Matt Brubeck wrote:
> > I get a segfault when I try to open test/wp/footer.abw. This happens
> > under Windows and Linux.
> > 
> > fl_BlockLayout::getNewLine() is trying to get a Container from a
> > HdrFtrSectionLayout. The relevant functions in fl_HdrFtrSectionLayout
> > simply assert and return NULL whenever they are called. The code doesn't
> > check for this, and tries to use the NULL pointer.
> > 
> > I tried to fix it, but don't know the code well enough (yet). I filed
> > bug #1053: http://www.abisource.com/bugzilla/show_bug.cgi?id=1053
> > 
> 
> Some more info on this.  It turns out that the problem stems from having 
> text in the footer.  Multiple fields, or single fields are not a problem, 
> but any text causes that segfault.  This happens on both headers and 
> footers, and is irrespective of other document content.  In fact, images
> in headers/footers works, as long as there is no text.  
> 
> The next step is figuring out when this broke.  It appears to have broken
> more than one week ago, but I'll let people know what I find out.  

Culprit found.  The breakage appeared, AFAICT, after Martin's checkin
on the 27th of October.  This was a fix for missing last lines in 
Word documents.  Sadly, the patch he applied will not reverse currently.
So we have to figure out why it broke footer import.  

The email he sent was:  
http://www.abisource.com/mailinglists/abiword-dev/00/October/0380.html

Attached is the offending patch.  
           
        sam th               
        [EMAIL PROTECTED]
        http://www.abisource.com/~sam/
        GnuPG Key:  
        http://www.abisource.com/~sam/key
Index: abi/src/text/fmt/xp/fl_AutoNum.cpp
diff -u abi/src/text/fmt/xp/fl_AutoNum.cpp:1.20 abi/src/text/fmt/xp/fl_AutoNum.cpp:1.21
--- abi/src/text/fmt/xp/fl_AutoNum.cpp:1.20     Wed Oct  4 20:30:43 2000
+++ abi/src/text/fmt/xp/fl_AutoNum.cpp  Fri Oct 27 02:25:29 2000
@@ -127,6 +127,11 @@
               *insPoint = 0;
               return;
        }
+        if(depth > 0 && m_List_Type >= BULLETED_LIST)
+       {
+              *insPoint = 0;
+              return;
+       }
 
        // TODO This is a bit of a hack to split the delim string. It would be 
        // TODO nice to clear it up.
@@ -150,13 +155,13 @@
                i++;
        }
        rightDelim[i - rTmp] = '\0';
-       UT_DEBUGMSG(("Left Delim: %s, Right Delim: %s\n", leftDelim, rightDelim));
+       //UT_DEBUGMSG(("Left Delim: %s, Right Delim: %s\n", leftDelim, rightDelim));
        
 
         if(m_pParent != NULL  && m_List_Type < BULLETED_LIST)
        {
               m_pParent->_getLabelstr( labelStr, insPoint, depth+1,getFirstItem());
-              UT_DEBUGMSG(("JORDAN: Parent Label: %s\n", labelStr));
+              //     UT_DEBUGMSG(("JORDAN: Parent Label: %s\n", labelStr));
               if(*insPoint != 0)
               {
                        psz = UT_XML_strlen(m_pszDecimal);
@@ -527,7 +532,7 @@
 
 void fl_AutoNum::update(UT_uint32 start)
 {
-       UT_DEBUGMSG(("Entering update\n"));
+  //   UT_DEBUGMSG(("Entering update\n"));
        if(isUpdating())
                return;
        //_calculateLabelStr(0);
@@ -541,11 +546,11 @@
 
 inline void fl_AutoNum::_updateItems(UT_uint32 start)
 {
-       UT_DEBUGMSG(("Entering _updateItems\n"));
+  //   UT_DEBUGMSG(("Entering _updateItems\n"));
        m_bUpdatingItems = UT_TRUE;
        for (UT_uint32 i = start; i < m_pItems.getItemCount(); i++)
        {
-               UT_DEBUGMSG(("Entering _updateItems for loop\n"));
+         //    UT_DEBUGMSG(("Entering _updateItems for loop\n"));
                fl_Layout * pTmp = (fl_Layout *)m_pItems.getNthItem(i);
                pTmp->listUpdate();
        }
Index: abi/src/text/fmt/xp/fl_BlockLayout.cpp
diff -u abi/src/text/fmt/xp/fl_BlockLayout.cpp:1.197 
abi/src/text/fmt/xp/fl_BlockLayout.cpp:1.198
--- abi/src/text/fmt/xp/fl_BlockLayout.cpp:1.197        Tue Oct 10 01:22:08 2000
+++ abi/src/text/fmt/xp/fl_BlockLayout.cpp      Fri Oct 27 02:25:29 2000
@@ -894,6 +894,14 @@
 {
        // When loading a document, there may not have been created
        // lines yet. Get a first one created and hope for the best...
+        // Sevior: Ah here is one source of the multi-level list bug we
+        // need a last line from the previous block before we call this.
+        if(getPrev()!= NULL && getPrev()->getLastLine()==NULL)
+        {
+               UT_DEBUGMSG(("SEVIOR: in _breakLineAfterRun no LastLine \n"));
+               UT_DEBUGMSG(("SEVIOR getPrev = %d this = %d \n",getPrev(),this));
+               //UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
+       }
        if (!m_pFirstLine)
                _stuffAllRunsOnALine();
 
@@ -1115,7 +1123,8 @@
                        {
                                 // Previous block exists but doesn't have a last line.
                                 // This is a BUG. Try a work around for now. TODO Fix 
this elsewhere
-                                UT_DEBUGMSG(("SEVIOR: BUG!! Previous block exists 
with no last line, try to reformat the block \n"));
+                                UT_DEBUGMSG(("SEVIOR: BUG!!! Previous block exists 
+with no last line, try to reformat the block \n"));
+                                //abort();
                                 m_pPrev->format();
                        }
                }
@@ -2203,6 +2212,13 @@
         if(pView)
                pView->eraseInsertionPoint();
        PT_BufIndex bi = pcrs->getBufIndex();
+        if(getPrev()!= NULL && getPrev()->getLastLine()==NULL)
+        {
+               UT_DEBUGMSG(("SEVIOR: in _breakLineAfterRun no LastLine \n"));
+               UT_DEBUGMSG(("SEVIOR getPrev = %d this = %d \n",getPrev(),this));
+               //              UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
+       }
+
        const UT_UCSChar* pChars = m_pDoc->getPointer(bi);
 
        /*
@@ -2341,6 +2357,12 @@
 {
        fp_Run* pNewRun = new fp_ForcedPageBreakRun(this, m_pLayout->getGraphics(), 
blockOffset, 1);
        UT_ASSERT(pNewRun);     // TODO check for outofmem
+        if(getPrev()!= NULL && getPrev()->getLastLine()==NULL)
+        {
+               UT_DEBUGMSG(("SEVIOR: in _breakLineAfterRun no LastLine \n"));
+               UT_DEBUGMSG(("SEVIOR getPrev = %d this = %d \n",getPrev(),this));
+               //UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
+       }
 
        UT_Bool bResult = _doInsertRun(pNewRun);
        if (bResult)
Index: abi/src/text/fmt/xp/fl_DocListener.cpp
diff -u abi/src/text/fmt/xp/fl_DocListener.cpp:1.79 
abi/src/text/fmt/xp/fl_DocListener.cpp:1.80
--- abi/src/text/fmt/xp/fl_DocListener.cpp:1.79 Tue Aug  1 00:38:30 2000
+++ abi/src/text/fmt/xp/fl_DocListener.cpp      Fri Oct 27 02:25:29 2000
@@ -78,10 +78,26 @@
                        fl_Layout * pL = (fl_Layout *)sfh;
                        UT_ASSERT(pL->getType() == PTX_Block);
                        fl_BlockLayout * pBL = static_cast<fl_BlockLayout *>(pL);
+                       if(pBL->getPrev()!= NULL && 
+pBL->getPrev()->getLastLine()==NULL)
+                         {
+                           UT_DEBUGMSG(("SEVIOR: in DocListner before no LastLine 
+\n"));
+                           UT_DEBUGMSG(("SEVIOR getPrev = %d this = %d 
+\n",pBL->getPrev(),pBL));
+                           pBL->getPrev()->format();
+
+                         }
+
                        PT_BlockOffset blockOffset = pcrs->getBlockOffset();
                        UT_uint32 len = pcrs->getLength();
                        fl_SectionLayout* pBLSL = pBL->getSectionLayout();
                        bResult = pBLSL->bl_doclistener_populateSpan(pBL, pcrs, 
blockOffset, len);
+                       if(pBL->getLastLine()==NULL)
+                         {
+                           UT_DEBUGMSG(("SEVIOR: in  DocListner after no LastLine 
+\n"));
+                           UT_DEBUGMSG(("SEVIOR getPrev = %d this = %d 
+\n",pBL->getPrev(),pBL));
+                           pBL->format();
+                           //UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
+                         }
+
                        goto finish_up;
                }
 
Index: abi/src/text/fmt/xp/fl_SectionLayout.cpp
diff -u abi/src/text/fmt/xp/fl_SectionLayout.cpp:1.60 
abi/src/text/fmt/xp/fl_SectionLayout.cpp:1.62
--- abi/src/text/fmt/xp/fl_SectionLayout.cpp:1.60       Tue Aug  1 00:38:30 2000
+++ abi/src/text/fmt/xp/fl_SectionLayout.cpp    Fri Oct 27 02:25:29 2000
@@ -260,6 +260,13 @@
 
 UT_Bool fl_SectionLayout::bl_doclistener_populateSpan(fl_BlockLayout* pBL, const 
PX_ChangeRecord_Span * pcrs, PT_BlockOffset blockOffset, UT_uint32 len)
 {
+        if(pBL->getPrev()!= NULL && pBL->getPrev()->getLastLine()==NULL)
+        {
+               UT_DEBUGMSG(("SEVIOR: in bl_doclistner_pop no LastLine \n"));
+               UT_DEBUGMSG(("SEVIOR getPrev = %d this = %d \n",pBL->getPrev(),pBL));
+               //  UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
+       }
+
        return pBL->doclistener_populateSpan(pcrs, blockOffset, len);
 }
 
@@ -573,6 +580,18 @@
        while (pBL)
        {
                pBL->format();
+               UT_sint32 count = 0;
+               while(pBL->getLastLine() == NULL || pBL->getFirstLine()==NULL)
+               {
+                      UT_DEBUGMSG(("Error formatting a block try again \n"));
+                      count = count + 1;
+                      pBL->format();
+                      if(count > 3)
+                      {
+                             UT_DEBUGMSG(("Give up trying to format. Hope for the 
+best :-( \n"));
+                             break;
+                      }
+               }
                pBL = pBL->getNext();
        }
 
@@ -1109,7 +1128,6 @@
        fp_Line* pCurrentLine = pFirstBlock->getFirstLine();
                
        fp_Column* pCurColumn = (fp_Column*) getFirstContainer();
-       UT_ASSERT(pCurColumn);
 
        while (pCurColumn)
        {

PGP signature

Reply via email to