[PyKDE] Model indexes and internal pointers

Arve Knudsen arve.knudsen at gmail.com
Tue Jul 18 09:35:17 BST 2006


On 7/18/06, David Boddie <david at boddie.org.uk> wrote:
> On Tue Jul 18 00:23:47 MEST 2006, Phil Thompson wrote:
> > There are plenty of other places where you have to keep an external
> > reference to stop an object being garbage collected causing a crash. I just
> > need to decide if this is worth making a special case.
>
> I'm in favour of allowing model indexes to take references to Python objects,
> as long as everyone realises that you can't store objects in indexes and
> expect to get them back later. However, model indexes are supposed to be
> lightweight objects and there may be a performance penalty to pay for adding
> extra code to manage object reference counting.

When you say that model indexes are temporary, do you mean that if one
keeps a reference to a wrapping Python object, the underlying C++
object may still get destroyed? That doesn't apply to my case at
least, I only need to access indexes' associated data in reimplemented
model methods (such as data()).

Anyway, I think that models and views are so integral to Qt
programming now that some robustness towards passing data between them
should definitely be considered.

Arve




More information about the PyQt mailing list