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

Cannot destroy QCoreApplication with shiboken2.delete

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.15.4
    • 5.15.2
    • PySide, Shiboken
    • None
    • tested on macOS 10.15.7, PySide2 5.15.2, python 3.8.6
    • 98aba46414b666c27df3904d2b4313f0a16e05dc (pyside/pyside-setup/dev) db9e8e575538c627f9808592e895a9c544d16c4e (pyside/pyside-setup/6.0) ac2a77d7bd84aa01c16916d473b3c77c541b03a8 (pyside/pyside-setup/5.15)

    Description

      I'm aware that "most applications shouldn't need to recreate a QApplication", but use-cases aside for the moment, when I try to delete and recreate a QCoreApplication using shiboken2.app, no QObject.destroyed signal is ever emitted, and it still instructs me to destroy the QCoreApplication. Here is an example of what I would have expected would work (similar code works in PyQt5):

      
      In [1]: from PySide2.QtCore import QCoreApplication
      
      In [2]: app = QCoreApplication([])
      
      In [3]: import shiboken2
      
      In [4]: app
      Out[4]: <PySide2.QtCore.QCoreApplication(0x7f8ee659b210) at 0x7f8eb97fc2d0>
      
      In [5]: shiboken2.delete(app)
      
      In [6]: shiboken2.isValid(app)
      Out[6]: False
      
      In [7]: app
      
      # as expected
      # ...
      RuntimeError: Internal C++ object (PySide2.QtCore.QCoreApplication) already deleted.
      
      In [8]: app2 = QCoreApplication([])
      ---------------------------------------------------------------------------
      RuntimeError                              Traceback (most recent call last)
      <ipython-input-8-8438d43d5358> in <module>
      ----> 1 app2 = QCoreApplication([])
      
      RuntimeError: Please destroy the QCoreApplication singleton before creating a new QCoreApplication instance.
      
      

      if this isn't a bug, then any advice on destroying and recreating an app would be appreciated. Thanks!

      Attachments

        Issue Links

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

          Activity

            People

              ctismer Christian Tismer
              talley Talley Lambert
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes