aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaime Resano <[email protected]>2024-11-22 15:51:18 +0100
committerJaime Resano <[email protected]>2024-11-25 11:11:46 +0000
commit4274aaed897e713fc628e4dcec93ac6a5f704af0 (patch)
treed19345c8d515988857fb78a3f6d203b00cd23a1f
parent78ac4b40a5da489036885def98e5108fdd56cdbc (diff)
Delete QQmlApplicationEngine on application exit
Due to the API limitations, we have to ensure that the engine is deleted before other parts of the application is deleted. Otherwise exposing objects using setInitialProperties() or setContextProperty() for example will cause warnings to be printed. It is a good practice to always delete the engine manually so all the code should be consistent. Task-number: PYSIDE-1612 Pick-to: 6.8 Change-Id: I01f16359e9d90cefd5957708fe12ce489bd7edc0 Reviewed-by: Jaime Resano <[email protected]> Reviewed-by: Friedemann Kleint <[email protected]>
-rw-r--r--examples/bluetooth/heartrate_game/main.py4
-rw-r--r--examples/bluetooth/lowenergyscanner/main.py4
-rw-r--r--examples/demos/colorpaletteclient/main.py4
-rw-r--r--examples/demos/osmbuildings/main.py5
-rw-r--r--examples/location/mapviewer/main.py4
-rw-r--r--examples/qml/editingmodel/main.py6
-rw-r--r--examples/qml/textproperties/main.py4
-rw-r--r--examples/quick3d/customgeometry/main.py4
-rw-r--r--examples/quick3d/intro/main.py4
-rw-r--r--examples/quick3d/proceduraltexture/main.py5
-rw-r--r--examples/quickcontrols/contactslist/main.py4
-rw-r--r--examples/quickcontrols/filesystemexplorer/main.py4
-rw-r--r--examples/quickcontrols/gallery/gallery.py4
-rw-r--r--examples/tutorials/finance_manager/part1/main.py4
-rw-r--r--examples/tutorials/finance_manager/part2/main.py4
-rw-r--r--examples/tutorials/finance_manager/part3/Frontend/main.py4
-rw-r--r--examples/webenginequick/nanobrowser/quicknanobrowser.py4
-rw-r--r--examples/webview/minibrowser/main.py4
-rw-r--r--sources/pyside-tools/qml.py4
-rw-r--r--sources/pyside6/doc/tutorials/extendedexplorer/main.py8
-rw-r--r--sources/pyside6/doc/tutorials/qmlintegration/main.py4
-rw-r--r--sources/pyside6/doc/tutorials/qmlsqlintegration/main.py3
22 files changed, 57 insertions, 38 deletions
diff --git a/examples/bluetooth/heartrate_game/main.py b/examples/bluetooth/heartrate_game/main.py
index 076085f0c..00df7de6a 100644
--- a/examples/bluetooth/heartrate_game/main.py
+++ b/examples/bluetooth/heartrate_game/main.py
@@ -49,6 +49,6 @@ if __name__ == '__main__':
if not engine.rootObjects():
sys.exit(-1)
- ex = QCoreApplication.exec()
+ exit_code = QCoreApplication.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/bluetooth/lowenergyscanner/main.py b/examples/bluetooth/lowenergyscanner/main.py
index 6b84a1031..35c82ed37 100644
--- a/examples/bluetooth/lowenergyscanner/main.py
+++ b/examples/bluetooth/lowenergyscanner/main.py
@@ -23,6 +23,6 @@ if __name__ == '__main__':
if not engine.rootObjects():
sys.exit(-1)
- ex = QCoreApplication.exec()
+ exit_code = QCoreApplication.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/demos/colorpaletteclient/main.py b/examples/demos/colorpaletteclient/main.py
index a35bdde80..f32c15805 100644
--- a/examples/demos/colorpaletteclient/main.py
+++ b/examples/demos/colorpaletteclient/main.py
@@ -29,6 +29,6 @@ if __name__ == "__main__":
if not engine.rootObjects():
sys.exit(-1)
- ex = app.exec()
+ exit_code = app.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/demos/osmbuildings/main.py b/examples/demos/osmbuildings/main.py
index 67a399766..313e3a0fb 100644
--- a/examples/demos/osmbuildings/main.py
+++ b/examples/demos/osmbuildings/main.py
@@ -18,6 +18,7 @@ if __name__ == "__main__":
engine.loadFromModule("OSMBuildings", "Main")
if not engine.rootObjects():
sys.exit(-1)
- ex = QCoreApplication.exec()
+
+ exit_code = QCoreApplication.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/location/mapviewer/main.py b/examples/location/mapviewer/main.py
index f982572d1..1eefb497c 100644
--- a/examples/location/mapviewer/main.py
+++ b/examples/location/mapviewer/main.py
@@ -71,6 +71,6 @@ if __name__ == "__main__":
QMetaObject.invokeMethod(items[0], "initializeProviders",
Q_ARG("QVariant", parameters))
- ex = application.exec()
+ exit_code = application.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/qml/editingmodel/main.py b/examples/qml/editingmodel/main.py
index aa39460aa..cccbd2b0d 100644
--- a/examples/qml/editingmodel/main.py
+++ b/examples/qml/editingmodel/main.py
@@ -16,7 +16,9 @@ if __name__ == "__main__":
engine = QQmlApplicationEngine()
qml_file = Path(__file__).parent / "main.qml"
engine.load(QUrl.fromLocalFile(qml_file))
-
if not engine.rootObjects():
sys.exit(-1)
- sys.exit(app.exec())
+
+ exit_code = app.exec()
+ del engine
+ sys.exit(exit_code)
diff --git a/examples/qml/textproperties/main.py b/examples/qml/textproperties/main.py
index ce644f754..802e9f94b 100644
--- a/examples/qml/textproperties/main.py
+++ b/examples/qml/textproperties/main.py
@@ -74,4 +74,6 @@ if __name__ == '__main__':
if not engine.rootObjects():
sys.exit(-1)
- sys.exit(app.exec())
+ exit_code = app.exec()
+ del engine
+ sys.exit(exit_code)
diff --git a/examples/quick3d/customgeometry/main.py b/examples/quick3d/customgeometry/main.py
index 985943208..bff6b4a95 100644
--- a/examples/quick3d/customgeometry/main.py
+++ b/examples/quick3d/customgeometry/main.py
@@ -27,4 +27,6 @@ if __name__ == "__main__":
if not engine.rootObjects():
sys.exit(-1)
- sys.exit(app.exec())
+ exit_code = app.exec()
+ del engine
+ sys.exit(exit_code)
diff --git a/examples/quick3d/intro/main.py b/examples/quick3d/intro/main.py
index a35ec6a45..bb0c95d34 100644
--- a/examples/quick3d/intro/main.py
+++ b/examples/quick3d/intro/main.py
@@ -22,4 +22,6 @@ if __name__ == "__main__":
if not engine.rootObjects():
sys.exit(-1)
- sys.exit(app.exec())
+ exit_code = app.exec()
+ del engine
+ sys.exit(exit_code)
diff --git a/examples/quick3d/proceduraltexture/main.py b/examples/quick3d/proceduraltexture/main.py
index 292acfe61..05ff49378 100644
--- a/examples/quick3d/proceduraltexture/main.py
+++ b/examples/quick3d/proceduraltexture/main.py
@@ -25,7 +25,6 @@ if __name__ == "__main__":
if not engine.rootObjects():
sys.exit(-1)
- ex = app.exec()
+ exit_code = app.exec()
del engine
-
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/quickcontrols/contactslist/main.py b/examples/quickcontrols/contactslist/main.py
index 41c7142b3..c9ce11e51 100644
--- a/examples/quickcontrols/contactslist/main.py
+++ b/examples/quickcontrols/contactslist/main.py
@@ -24,6 +24,6 @@ if __name__ == '__main__':
if not engine.rootObjects():
sys.exit(-1)
- ex = app.exec()
+ exit_code = app.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/quickcontrols/filesystemexplorer/main.py b/examples/quickcontrols/filesystemexplorer/main.py
index 97bf9852d..9c63ec385 100644
--- a/examples/quickcontrols/filesystemexplorer/main.py
+++ b/examples/quickcontrols/filesystemexplorer/main.py
@@ -46,4 +46,6 @@ if __name__ == '__main__':
fsm = engine.singletonInstance("FileSystemModule", "FileSystemModel")
fsm.setInitialDirectory(args[0])
- sys.exit(app.exec())
+ exit_code = app.exec()
+ del engine
+ sys.exit(exit_code)
diff --git a/examples/quickcontrols/gallery/gallery.py b/examples/quickcontrols/gallery/gallery.py
index 7e93e083c..d454cf53e 100644
--- a/examples/quickcontrols/gallery/gallery.py
+++ b/examples/quickcontrols/gallery/gallery.py
@@ -50,4 +50,6 @@ if __name__ == "__main__":
window = rootObjects[0]
window.setIcon(QIcon(':/qt-project.org/logos/pysidelogo.png'))
- sys.exit(app.exec())
+ exit_code = app.exec()
+ del engine
+ sys.exit(exit_code)
diff --git a/examples/tutorials/finance_manager/part1/main.py b/examples/tutorials/finance_manager/part1/main.py
index 444ed094e..7a794db0e 100644
--- a/examples/tutorials/finance_manager/part1/main.py
+++ b/examples/tutorials/finance_manager/part1/main.py
@@ -20,6 +20,6 @@ if __name__ == '__main__':
if not engine.rootObjects():
sys.exit(-1)
- ex = app.exec()
+ exit_code = app.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/tutorials/finance_manager/part2/main.py b/examples/tutorials/finance_manager/part2/main.py
index 3b8616a45..bff297605 100644
--- a/examples/tutorials/finance_manager/part2/main.py
+++ b/examples/tutorials/finance_manager/part2/main.py
@@ -25,6 +25,6 @@ if __name__ == '__main__':
if not engine.rootObjects():
sys.exit(-1)
- ex = app.exec()
+ exit_code = app.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/tutorials/finance_manager/part3/Frontend/main.py b/examples/tutorials/finance_manager/part3/Frontend/main.py
index f85125c73..bb90d00e8 100644
--- a/examples/tutorials/finance_manager/part3/Frontend/main.py
+++ b/examples/tutorials/finance_manager/part3/Frontend/main.py
@@ -21,6 +21,6 @@ if __name__ == '__main__':
if not engine.rootObjects():
sys.exit(-1)
- ex = app.exec()
+ exit_code = app.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/examples/webenginequick/nanobrowser/quicknanobrowser.py b/examples/webenginequick/nanobrowser/quicknanobrowser.py
index b246ac167..e5c667c51 100644
--- a/examples/webenginequick/nanobrowser/quicknanobrowser.py
+++ b/examples/webenginequick/nanobrowser/quicknanobrowser.py
@@ -68,4 +68,6 @@ if __name__ == '__main__':
QMetaObject.invokeMethod(engine.rootObjects()[0], "load", Q_ARG("QVariant", url))
- app.exec()
+ exit_code = app.exec()
+ del engine
+ sys.exit(exit_code)
diff --git a/examples/webview/minibrowser/main.py b/examples/webview/minibrowser/main.py
index bee3189eb..24ca3e847 100644
--- a/examples/webview/minibrowser/main.py
+++ b/examples/webview/minibrowser/main.py
@@ -55,6 +55,6 @@ if __name__ == "__main__":
if not engine.rootObjects():
sys.exit(-1)
- ex = app.exec()
+ exit_code = app.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/sources/pyside-tools/qml.py b/sources/pyside-tools/qml.py
index d36e86347..f138d2e7e 100644
--- a/sources/pyside-tools/qml.py
+++ b/sources/pyside-tools/qml.py
@@ -243,4 +243,6 @@ if __name__ == "__main__":
if args.config == "resizeToItem":
logging.info("qml: Not a QQuickview item. resizeToItem is done by default")
- sys.exit(app.exec())
+ exit_code = app.exec()
+ del engine
+ sys.exit(exit_code)
diff --git a/sources/pyside6/doc/tutorials/extendedexplorer/main.py b/sources/pyside6/doc/tutorials/extendedexplorer/main.py
index 4afb08b6d..13a1c5e5b 100644
--- a/sources/pyside6/doc/tutorials/extendedexplorer/main.py
+++ b/sources/pyside6/doc/tutorials/extendedexplorer/main.py
@@ -11,8 +11,8 @@ This example shows how to customize Qt Quick Controls by implementing a simple f
# import FileSystemModule.rc_icons
# import FileSystemModule.rc_app
-from scheme_manager import SchemeManager
-from editormodels import FileSystemModel
+from scheme_manager import SchemeManager # noqa: F401
+from editormodels import FileSystemModel # noqa: F401
import PySide6
from PySide6.QtGui import QGuiApplication, QIcon
from PySide6.QtQml import QQmlApplicationEngine
@@ -48,4 +48,6 @@ if __name__ == '__main__':
fsm = engine.singletonInstance("FileSystemModule", "FileSystemModel")
fsm.setInitialDirectory(args[0])
- sys.exit(app.exec())
+ exit_code = app.exec()
+ del engine
+ sys.exit(exit_code)
diff --git a/sources/pyside6/doc/tutorials/qmlintegration/main.py b/sources/pyside6/doc/tutorials/qmlintegration/main.py
index f08ad099f..aa8706f93 100644
--- a/sources/pyside6/doc/tutorials/qmlintegration/main.py
+++ b/sources/pyside6/doc/tutorials/qmlintegration/main.py
@@ -59,6 +59,6 @@ if __name__ == '__main__':
if not engine.rootObjects():
sys.exit(-1)
- ex = app.exec()
+ exit_code = app.exec()
del engine
- sys.exit(ex)
+ sys.exit(exit_code)
diff --git a/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py b/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py
index e42f8f2e9..e514adda8 100644
--- a/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py
+++ b/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py
@@ -55,5 +55,6 @@ if __name__ == "__main__":
if not engine.rootObjects():
sys.exit(-1)
- app.exec()
+ exit_code = app.exec()
del engine
+ sys.exit(exit_code)