Exception thrown in KHTMLPart::selection()

John Tapsell john at geola.co.uk
Tue Jan 18 19:22:30 GMT 2005


I have the KHTMLPart::selection() working now ... except one problem :)   

I have:

   int o_end = 0;
    n = d->m_selectionEnd.handle();
    if(!n->parentNode()) {
        r.setEnd( d->m_selectionEnd, d->m_endOffset );
    } else if(!n->renderer()) {
        r.setEnd( d->m_selectionEnd, d->m_endOffset );
    } else if(!n->renderer()->isReplaced() && !n->renderer()->isBR()) {
        r.setEnd( d->m_selectionEnd, d->m_endOffset );
    } else {
        while ((n = n->previousSibling()))
            o_end++;
        r.setEnd( d->m_selectionEnd.parentNode(), o_end + d->m_endOffset );
    }

The problem is:
      } else if(!n->renderer()->isReplaced() && !n->renderer()->isBR()) {
        r.setEnd( d->m_selectionEnd, d->m_endOffset );

This is causing an exception (INDEX_SIZE_ERR).  I can only reproduce this bug 
in kopete.  I think it's when you have something selected then someone sends 
you a message so that it changes.

Any ideas?  It's quite serious as it crashes kopete in head :(
I really need to get this fixed :(

John

On Thursday 13 January 2005 21:35, you wrote:
> Am Donnerstag, 13. Januar 2005 18:45 schrieb John Tapsell:
> > I can't find the email where we were discussing this.. very wierd.
> >
> > You sent me the below quoted email.  I implemented this, but it doesn't
> > work quite right.
>
> Yeah, I remember.
>
> > The problem is if you have something like:
> >
> > <img..>text1<img..>text2
> >
> > and you select "text1<img..>"  it counts that as selecting
> > "text1<img..>text2".
>
> Ok, can you give me the debug output of the node name of m_selectionStart,
> the value of m_startOffset and the node name of m_selectionEnd, the value
> of m_endOffset of said selection
> (something like kdDebug(6000) << "(" <<
> m_selectionStart.handle()->nodeName() << "@" << m_selectionStart.handle()
> << "," << m_startOffset << ")" << <same for end> ... )?
>
> I can't test it myself as said codepath does not exist anymore in
> designmode_branch.
>
> [...]
>
> mfg
>  Leo




More information about the kfm-devel mailing list