Re: Field bugs was Re: commit: undebugged Lists and Fields.


Subject: Re: Field bugs was Re: commit: undebugged Lists and Fields.
From: Sam TH (sam@uchicago.edu)
Date: Wed Nov 08 2000 - 21:13:44 CST


On Thu, Nov 09, 2000 at 01:28:44PM +1100, Martin Sevior wrote:
>
>
> On Wed, 8 Nov 2000, Sam TH wrote:
> >
> > The date&time field segfaults if you undo the insert. This is a
> > showstopper.
> >
>
> Yuck! Thanks for the info. I'll work on this.

Ha - I win. The following patch fixes the problem for me.
As it turns out, the problem was much worse than it appeared. Just
try opening a new document, and hitting the left arrow key. Instant
segfault. This fixes that, and the undo of fields at the beginning
of the document, and I think a bunch of other problems. Detailed
explanation after the patch.

Patch:

diff -u -r1.307 fv_View.cpp
--- src/text//fmt/xp/fv_View.cpp 2000/11/09 01:00:57 1.307
+++ src/text//fmt/xp/fv_View.cpp 2000/11/09 02:59:46
@@ -4567,6 +4567,9 @@
         UT_sint32 iPointHeight;
 
         fl_BlockLayout* pBlock = _findBlockAtPosition(pos);
+ while(!pBlock)
+ pBlock = _findBlockAtPosition((PT_DocPosition) pos++);
+
         UT_ASSERT(pBlock);
         fp_Run* pRun = pBlock->findPointCoords(pos, bEOL, xPoint, yPoint, iPointHeight);
 
Explanation:

The problem was, we were asking for the Block in the document at or before
pos. However, if pos == 1, then there was no block that fit these
criteria. Then, when you try to use pBlock about at the bottom of the patch
there, it segfaults. In order to fix this, I just said that if we don't
find the block there, we keep going through the document until we find
one.

This could have been done deeper in the call chain resulting from
_findBlockAtPosition(), but this was where the syntax was easiest.

As this isn't really the answer we want in the case that we have to
use the while loop, this may introduce bugs. Therefore, I haven't
committed it yet. If people think that it's not a good idea, I'll
hold off, but this issue has to be fixed before 0.7.12 goes out.

           
        sam th
        sam@uchicago.edu
        http://www.abisource.com/~sam/
        GnuPG Key:
        http://pgp5.ai.mit.edu:11371/pks/lookup?op=get&search=0xCABD33FC




This archive was generated by hypermail 2b25 : Wed Nov 08 2000 - 21:13:46 CST