[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] QML garbage collects the model
From: Phil Thompson <phil () riverbankcomputing ! com>
Date: 2014-07-23 13:05:55
Message-ID: 0c1e8c181f308c4efc5d277dc947e37c () www ! riverbankcomputing ! com
[Download RAW message or body]
On 22/07/2014 3:02 pm, Nenad Ognjanovic wrote:
> This is a follow up on the previous thread "QML, pyqtSlot and
> ownership".
> The problem I'm having is that QML garbage collects the model which is
> in use by ListView. ListView initially gets the model by calling
> Python function (pyqtSlot) which instantiates and returns the model
> (the function changes the ownership of the model before returning).
> This works fine until the garbage collector gets triggered, at which
> point QML will collect the model, and ListView will have missing items
> after scrolling.
>
> I have prepared the example that demonstrates this, which can easily
> be tweaked to use different object ownership transfer methods and
> model data types, as described in the source code.
> The code is attached, and can also be checked out at this gist:
> https://gist.github.com/bgr/1e43b12f088e07465afb
> In its core the code could be 3x shorter, but I've expanded it to
> cover a couple of different approaches. There is a simpler version of
> the code at revision #1 of the gist.
> I have also tried registering DummyModel and DummyObject with
> qmlRegisterType after I've uploaded the example, it also has no
> effect.
>
> I have no clue whether it's a bug or if I'm doing something totally
> wrong, but one important thing to note is that when
> GUIEntryPoint.get_model is converted to be a pyqtProperty the problem
> doesn't occur.
The fact that the model is collected implies that the ownership has been
transferred correctly. But I have no idea why QML should think the model
is no longer needed - smells like a Qt bug.
A C++ version of your example would probably be useful to compare with.
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic