[PySide] Problems with QStyle deletion

John Ehresman jpe at wingware.com
Thu Nov 15 23:52:06 CET 2012

I'm trying to fix a bug that causes segfaults if QApplication.style()
and QApplication.setStyle() are used repeatedly.  I think the issue is:

1) a PyObject* is created for the QStyle* returned by style() and its
shiboken parent is set to the global app which adds 1 to the refcount

2) the next call to setStyle delete's the C++ QStyle but the PyObject*
remains in the binding map

3) at some future point, another C++ object is created with the same
address as the first QStyle* and unpredictable errors occur if the new
C++ object is not a QStyle

I was expecting pyside to connect to the destroyed signal (QStyle is a
QObject) and for the PyObject* to be removed from the binding map when
the QStyle is deleted, but that couldn't see that happening when I
stepped through the QObject destructor.

Any hints of how to fix this would be appreciated.



More information about the PySide mailing list