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
- relates to
-
PYSIDE-1470 Cannot destroy QCoreApplication with shiboken2.delete
- Closed