aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-01-04 19:10:52 +0100
committerChristian Tismer <tismer@stackless.com>2021-01-11 15:36:06 +0100
commit98aba46414b666c27df3904d2b4313f0a16e05dc (patch)
treecb90070b8d8938ed3918c5a2ba68a8038a9be3fc /sources/pyside6
parent8a115fcc3719af509a1abb91805729c06ce38443 (diff)
allow to use shiboken.delete() to delete Q*Application
This function should initially not allow deleting Q*Application with a shiboken.delete() function, but unfortunately some competitor can do that, so we will as well. Deletion of qApp needs knowledge about qApp. We add a hook function that calls the pyside function `destroyQCoreApplication`. A special problem was testing interactively. See the error description for the days long journey :) Change-Id: I34862425c2cb2cc80d6cafc22d25a867f96f3e0a Fixes: PYSIDE-1470 Pick-to: 6.0 Pick-to: 5.15 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/libpyside/pyside.cpp3
-rw-r--r--sources/pyside6/tests/pysidetest/qapp_like_a_macro_test.py5
2 files changed, 6 insertions, 2 deletions
diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp
index 75b3eb16f..22230703e 100644
--- a/sources/pyside6/libpyside/pyside.cpp
+++ b/sources/pyside6/libpyside/pyside.cpp
@@ -308,6 +308,9 @@ void initQApp()
*/
if (!qApp)
Py_DECREF(MakeQAppWrapper(nullptr));
+
+ // PYSIDE-1470: Register a function to destroy an application from shiboken.
+ setDestroyQApplication(destroyQCoreApplication);
}
PyObject *getMetaDataFromQObject(QObject *cppSelf, PyObject *self, PyObject *name)
diff --git a/sources/pyside6/tests/pysidetest/qapp_like_a_macro_test.py b/sources/pyside6/tests/pysidetest/qapp_like_a_macro_test.py
index 2a796cea8..2233b1b33 100644
--- a/sources/pyside6/tests/pysidetest/qapp_like_a_macro_test.py
+++ b/sources/pyside6/tests/pysidetest/qapp_like_a_macro_test.py
@@ -59,10 +59,11 @@ class qAppMacroTest(unittest.TestCase):
classes = (QtCore.QCoreApplication,
QtGui.QGuiApplication,
QtWidgets.QApplication)
+ fil = sys.stderr
for klass in classes:
- print("created", klass([]))
+ print("CREATED", klass([]), file=fil); fil.flush()
qApp.shutdown()
- print("deleted qApp", qApp)
+ print("DELETED qApp", qApp, file=fil); fil.flush()
# creating without deletion raises:
QtCore.QCoreApplication([])
with self.assertRaises(RuntimeError):