On 1/6/12 8:55 PM, Nathan Smith wrote:
As discussed in Bug 1041, this is indeed an ownership problem. Each C++ object
exposed to Python is wrapped with a C++ wrapper object. The wrapper object is
stored in a hash table (in C++) that maps the C++ object to a Python reference.
The hash table ensures that each time the C++ object is moved from C++ to
Python, it shows up to Python as the same reference. The key to the hash table
is the address of the object being shoved. When the C++ object is deleted, the
hash table entry is deleted.
This particular bug sees a problem when the QItemSelectionModel is shoved across
the boundary between C++ and Python. The ownership policy for
QItemSelectionModel is incorrect in PySide, so the wrapper object isn't deleted
when the C++ object dies, so the hash table entry isn't deleted. If a new
object is allocated that just so happens to land at the same memory address as
the now dead QItemSelectionModel, Shiboken looks in its hash table and finds the
old QItemSelectionModel wrapper object and assumes it has already shoved it
across the boundary. So when the new object shows up in Python, Python thinks
it's a QItemSelectionModel, which it isn't, object and hilarity ensues.
The patch provided on Bug 1041 fixes this problem by setting the appropriate
ownership model when a QAbstractItemView returns a QItemSelectionModel object,
but has been held up while waiting for the new object management code that is
now in PySide 1.1.0. The same bug exists in the development branch of the git
repository, so we still need to apply the patch.
For what it's worth, I see a similar problem when I try to get a
Python-implemented QAbstractItemModel object from the QItemSelectionModel
through the .model() method. I get segfaults when the process is shutting down.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
_______________________________________________
PySide mailing list
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside