diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-30 10:53:49 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-10-02 11:20:05 +0200 |
commit | 50e76d84bf6935e5d517c64c46b32c50d1e14ba9 (patch) | |
tree | c8276ad4680c197c52463c2bd4347f6eb1f68867 | |
parent | 670fdcc3f23493bc039a2676ce69892cc152dc6b (diff) |
qml: Make sure the qml tool deletes its application
Otherwise the shutdown mechanism for debug services doesn't work.
Fixes: QTBUG-78828
Change-Id: I4ede5861a300d5b5007036d71ed84409ec4d450f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | tools/qml/main.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 9edc90e050..daa278457d 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -60,6 +60,7 @@ #include <qqml.h> #include <qqmldebug.h> +#include <private/qmemory_p.h> #include <private/qtqmlglobal_p.h> #if QT_CONFIG(qml_animation) #include <private/qabstractanimation_p.h> @@ -68,6 +69,7 @@ #include <cstdio> #include <cstring> #include <cstdlib> +#include <memory> #define FILE_OPEN_EVENT_WAIT_TIME 3000 // ms @@ -398,23 +400,23 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory) int main(int argc, char *argv[]) { getAppFlags(argc, argv); - QCoreApplication *app = nullptr; + std::unique_ptr<QCoreApplication> app; switch (applicationType) { #ifdef QT_GUI_LIB case QmlApplicationTypeGui: - app = new LoaderApplication(argc, argv); + app = qt_make_unique<LoaderApplication>(argc, argv); break; #ifdef QT_WIDGETS_LIB case QmlApplicationTypeWidget: - app = new QApplication(argc, argv); - static_cast<QApplication *>(app)->setWindowIcon(QIcon(iconResourcePath)); + app = qt_make_unique<QApplication>(argc, argv); + static_cast<QApplication *>(app.get())->setWindowIcon(QIcon(iconResourcePath)); break; #endif // QT_WIDGETS_LIB #endif // QT_GUI_LIB case QmlApplicationTypeCore: Q_FALLTHROUGH(); default: // QmlApplicationTypeUnknown: not allowed, but we'll exit after checking apptypeOption below - app = new QCoreApplication(argc, argv); + app = qt_make_unique<QCoreApplication>(argc, argv); break; } @@ -598,7 +600,7 @@ int main(int argc, char *argv[]) if (files.count() <= 0) { #if defined(Q_OS_DARWIN) if (applicationType == QmlApplicationTypeGui) - exitTimerId = static_cast<LoaderApplication *>(app)->startTimer(FILE_OPEN_EVENT_WAIT_TIME); + exitTimerId = static_cast<LoaderApplication *>(app.get())->startTimer(FILE_OPEN_EVENT_WAIT_TIME); else #endif noFilesGiven(); |