aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/qml/main.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 070eee5c44..ea601ba946 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -51,6 +51,7 @@
#include <QFileInfo>
#include <QRegularExpression>
#include <QStringList>
+#include <QScopedPointer>
#include <QDebug>
#include <QStandardPaths>
#include <QTranslator>
@@ -172,13 +173,20 @@ class LoadWatcher : public QObject
public:
LoadWatcher(QQmlApplicationEngine *e, int expected)
: QObject(e)
+ , earlyExit(false)
, expect(expected)
, haveOne(false)
{
connect(e, SIGNAL(objectCreated(QObject*,QUrl)),
this, SLOT(checkFinished(QObject*)));
+ // QQmlApplicationEngine also connects quit() to QCoreApplication::quit
+ // but if called before exec() then QCoreApplication::quit does nothing
+ connect(e, SIGNAL(quit()),
+ this, SLOT(quit()));
}
+ bool earlyExit;
+
private:
int expect;
bool haveOne;
@@ -201,6 +209,11 @@ public Q_SLOTS:
exit(2);//Different return code from qFatal
}
}
+
+ void quit() {
+ //Will be checked before calling exec()
+ earlyExit = true;
+ }
};
void quietMessageHandler(QtMsgType type, const QMessageLogContext &ctxt, const QString &msg)
@@ -483,7 +496,7 @@ int main(int argc, char *argv[])
loadConf(confFile, !verboseMode);
//Load files
- LoadWatcher lw(&e, files.count());
+ QScopedPointer<LoadWatcher> lw(new LoadWatcher(&e, files.count()));
// Load dummy data before loading QML-files
if (!dummyDir.isEmpty() && QFileInfo (dummyDir).isDir())
@@ -515,6 +528,9 @@ int main(int argc, char *argv[])
}
}
+ if (lw->earlyExit)
+ return 0;
+
return app->exec();
}