[PySide] Segfault when exposing Python to QML

Stephan Deibel sdeibel at wingware.com
Thu Dec 13 17:20:17 CET 2012

Seth Less wrote:
> I'm running into issues where Python objects (subclasses of QObject 
> and other QT classes) that are exposed to QML (through a 
> QDeclarativeView) will often cause a segfault when they are accessed 
> by QML. I think this is because the Python objects are being garbage 
> collected on the Python side. (I assume this is because PySide doesn't 
> do reference counting on objects used by QML. Is this true?)
> I "fixed" this (more like worked around it temporary) by creating a 
> global object cache that never deallocates any of the objects in 
> question. As expected, this is unacceptable as it creates memory bloat 
> as the program execution time increases.
> What is the recommended way of using our objects in QML and not having 
> to store all of them permanently?
> Thanks for feed back. I'm enjoying PySIde and looking to get more into it!

There are object life cycle bugs in PySide that might lead to this, 
although I'm not sure if what you're seeing is specific to using QML or 
not.  If you're building PySide from sources you might want to try the 
experimental repositories below, which contain fixes for a subset of 
known issues:


- Stephan

More information about the PySide mailing list