Re: Changes to pf_Frag_Strux.cpp

From: Martin Sevior <msevior_at_gmail.com>
Date: Sun Jul 17 2011 - 14:30:25 CEST

Hi Volodymyr,

The number of fmt handles in the strux's should match the number of
views on the document. If it doesn't it is a sign that something is
going wrong. Rather than covering up these bugs with your patch I
think it far better to work out what is going wrong in the HTML
exporter.

Since you have a document that reproducibly provides theses asserts,
it is a great chance to track down the cause of the bug.

First we need to determine if the number of format handles is in error
from the import or the export. I suggest your write some test code in
pd_Document that scans the document and prints out the number of fmt
handles in each strux.

You can simply start at the first frag, call getNext() on it until you
hit the end of the document. Every time your frag is of Strux type
examine number of fmtHandles in the strux.

You should get one in every strux for each view you open.

If the code passes that test see if you can trap when things goes
wrong during export. Try calling the test code at various places of
the export process to isolate where things go wrong. When you do, fix
the bug (or report what is wrong here if you can't:-)

Cheers

Martin

On Sat, Jul 16, 2011 at 8:57 PM, Volodymyr Rudyj
<vladimir.rudoy@gmail.com> wrote:
>
> Good day !
>
> I need help and little code review. I`m working on improving HTML
> exporter (as you know, I`m using it in EPUB plugin). And while
> exporting some of the documents to HTML (and as a result to EPUB),
> e.g. abiword build instructions, assertion occurs which says that we
> tried to access element of the UT_vector by index which is out of
> range. I`ve found out that the reason is pf_Frag_Strux::getFmtHandle
> method. You can see stack trace at http://pastebin.com/nc6LSPe8 . So
> here is a little patch that fixes the problem. So what do you think
> about this patch?
>
> Thanks!
>
> ### Eclipse Workspace Patch 1.0
> #P abiword
> Index: src/text/ptbl/xp/pf_Frag_Strux.cpp
> ===================================================================
> --- src/text/ptbl/xp/pf_Frag_Strux.cpp  (revision 30045)
> +++ src/text/ptbl/xp/pf_Frag_Strux.cpp  (working copy)
> @@ -55,7 +55,7 @@
>
>  PL_StruxFmtHandle pf_Frag_Strux::getFmtHandle(PL_ListenerId lid) const
>  {
> -       if (m_vecFmtHandle.size() == 0) return 0;
> +       if ((m_vecFmtHandle.size() == 0) || (lid >= m_vecFmtHandle.size())) return 0;
>        return (PL_StruxFmtHandle)m_vecFmtHandle.getNthItem(lid);
>  }
>
Received on Sun Jul 17 14:30:33 2011

This archive was generated by hypermail 2.1.8 : Sun Jul 17 2011 - 14:30:33 CEST