Details
Description
Example of crashing code is in attachment.
Here's explanation of the issue as far as I could understand:
self.view.addItem('AAA')
Method addItem creates instance of QListWidgetItem. It's plain C++ object without any Python wrapper.
self.view.item(0)
Method QListWidget.item creates Python wrapper for created object and links it to the list using function Shiboken::Object::setParent, so the wrapper remains live till the exit from application potentially.
self.view.clear()
QListWidget.clear() clears internal list and destroys every item in it. After this the item object does no more exist, but the corresponding Python wrapper still does and it isn't marked as pointing to invalid object.
So there is two main ways how we can crash program using this invalid wrapper. The first is pretty obvious: try to call any method of previously acquired wrapper. Like in method crash1 from example.
The second way is more vague, and I don't understand the mechanism behind that, but it is more likely to occur and more dangerous. The crash occurs when you instantiate any descendant of QWidget class. It can be absolutely unrelated to the use of item() method so it's very hard to diagnose.