[PyQt] Problems with QQmlListProperty and Qml object ownership
Phil Thompson
phil at riverbankcomputing.com
Mon Nov 4 14:19:14 GMT 2013
On Tue, 29 Oct 2013 01:23:12 +0100, Juan Pedro Bolívar Puente
<raskolnikov at gnu.org> wrote:
> Hi!
>
> I am using PyQt5 and while I love the approach I have found a couple of
> serious issues, the latter one becoming a real showstopper. I have
> tried both with Qt 5.1 and 5.2.
>
> 1. Objects are not kept alive by Qml, meaning the application soon
> crashes if I do not keep the references alive. I am now keeping all my
> objects alive, but sadly this means I have some memory leaks now. Is
> there a way to fix it? I was considering moving parts of the
> application to C++ in the future: can this problem be solved in C++ or
> is it an inherent limitation of Qml memory model?
I would have expected QML to either pass a parent or to document that it
will take ownership of the created QObject. However it doesn't so you need
to keep a reference (or give it a parent) yourself. However I don't see how
you would then get memory leaks.
> 2. I am having very weird crashes with QQmlListProperty. First, my usage
> of QQmlListProperty looks a bit like this (not exactly, but you get the
> idea):
You need to provide a complete, self contained example that demonstrates
the problem.
Phil
More information about the PyQt
mailing list