aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-01-04 19:10:52 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-11 15:48:42 +0000
commitdb9e8e575538c627f9808592e895a9c544d16c4e (patch)
tree2babb8174e5c0a4ca8ffa77a6d15ced161035557 /sources/pyside6
parenta2c4cc01db8d09161349e0ac8489063c2d1383e7 (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 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 98aba46414b666c27df3904d2b4313f0a16e05dc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
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):