From ad3409a9dfe31ee7b710221be41a611ce79a2471 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 5 Apr 2024 11:04:30 +0800 Subject: Doc: don't use quit in snippet that exits upon load failure quit is for a successful exit. Failure to load QML is an error and should be treated as such. Pick-to: 6.5 Change-Id: I121349fb310d683f5e5bee4b6a324a9ea8947b6b Reviewed-by: Ulf Hermann Reviewed-by: Fabian Kosmale (cherry picked from commit 8bdbe3d50f26d18d81acdb74703c73c419ad922b) Reviewed-by: Qt Cherry-pick Bot --- src/qml/qml/qqmlapplicationengine.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index e2d9dceb16..82cc335c8e 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -257,10 +257,9 @@ void QQmlApplicationEnginePrivate::ensureLoadingFinishes(QQmlComponent *c) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - // quit on error - QObject::connect(&engine, QQmlApplicationEngine::objectCreationFailed, - QCoreApplication::instance(), QCoreApplication::quit, - Qt::QueuedConnection); + // exit on error + QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, + &app, []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(QUrl()); return app.exec(); \endcode -- cgit v1.2.3