Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-264

app crash after deleting C++-created objects

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9
    • 1.2.2
    • PySide
    • Tested on Windows 7, Python 3.4, PySide 1.2.2 and on Ubuntu 12.04 with Python 3.4, Qt 4.8 and PySide 1.2.2.
    • 819f7b47b1fcdc2ed88bdd07383bbd37a76848ac

    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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            veon Andrey Golynskiy
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes