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

QObject-based Python objects deleted when QApplication is explicitly deleted via Shiboken.detele()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.3.1, 6.5.3, 6.6.1
    • PySide, Shiboken
    • None
    • Linux/X11

    Description

      The following snippet can be used to show the unexpected behavior:

      import sys
      
      from PySide6 import QtCore, QtWidgets
      from shiboken6 import Shiboken
      
      
      class MyObject(QtCore.QObject):
          pass
      
      
      my_object = MyObject()
      
      app = QtWidgets.QApplication(sys.argv)
      QtCore.QTimer.singleShot(500, app.quit)
      app.exec()
      
      print('Shiboken.isValid:', Shiboken.isValid(my_object))
      Shiboken.delete(app)
      print('Shiboken.isValid:', Shiboken.isValid(my_object))
      

      Output:

      >>> Shiboken.isValid: True
      >>> Shiboken.isValid: False    <--- Unexpected
      

      my_object is deleted after the call to Shiboken.delete(app); if any of its methods is accessed, the following exception is raised:

      RuntimeError: Internal C++ object (MyObject) already deleted.
      

      The issue can be seen with other, more involved Qt types, such as QtCore.QSettings.

      Why would Shiboken.delete() end up deleting other, unrelated objects? This behavior cannot be reproduced with PySide 5.15.2.

      Attachments

        Issue Links

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

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              christian.aguilera.foundry Christian Aguilera
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes