← Back to team overview

ubuntu-phone team mailing list archive

Re: [QML] TypeError on delegate remove

 

Hello

Can you provide full example? Seems that you are doing something wrong.

2016-01-28 12:07 GMT+03:00 Olivier Tilloy <olivier.tilloy@xxxxxxxxxxxxx>:

> On Thu, Jan 28, 2016 at 9:37 AM, Sam Bull <sam.hacking@xxxxxxxx> wrote:
> > I have a custom component used as a delegate in a ListView. When this
> > object is removed I get the error:
> >
> >     TypeError: Cannot read property of null
> >
> > This is occurring on the rather standard line:
> >
> >     anchors { left: parent.left; right: parent.right }
> >
> > So, how am I supposed to clean up this error? The only thing I can
> > think of, is a hacky looking bit of code like:
> >
> >     anchors { left: (index == -1) ? 0 : parent.left; right: (index ==
> >     -1) ? 0 : parent.right }
>
> Try:
>
>   anchors {
>     left: parent ? parent.left : undefined
>     right: parent ? parent.right : undefined
>   }
>
> HTH,
>
>  Olivier
>
> --
> Mailing list: https://launchpad.net/~ubuntu-phone
> Post to     : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ubuntu-phone
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References