Yes, I would say that without the parenting, the created instance is never
referenced so it's deleted to soon and accessing it in QML causes the
segfault.
In the wiki example, the listmodel is instanciated "thingList =
 ThingListModel(things)" - increasing the refcount - and then set as a
property of the QDeclarativeContext, so there's no such problem.

Glad it worked !

Regards,
Yann


2013/1/13 Yosef Meller <[email protected]>

> **
>
> On Sunday 13 January 2013 12:06:45 Yann Lanthony wrote:
>
> > I've just tested to create a slot like yours (creating and returning an
>
> > instance of my custom model) in my minimal app and I have no segfault.
>
> > Maybe it's because you don't give your TargetListModel a parent. So you
>
> > create it and immediately return it but no one takes its ownership and
> it's
>
> > deleted to soon. This might explain the segfault.
>
>
>
> Setting a parent works!
>
>
>
> If I understand correctly, Python loses its last reference to it (which
> doesn't happen in the wiki example) but when setting a parent PySide
> increases the Python refcount so it doesn't get GCed until the parent
> object is GCed. Does that sound right?
>
>
>
> Thanks a lot,
>
> Yosef.
>
>
>
> _______________________________________________
> PySide mailing list
> [email protected]
> http://lists.qt-project.org/mailman/listinfo/pyside
>
>
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to