diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/main.cpp | 37 | ||||
-rw-r--r-- | tools/qmljs/qmljs.cpp | 8 |
2 files changed, 29 insertions, 16 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 7e59810cd8..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> @@ -64,8 +65,8 @@ #include <cstdlib> #define VERSION_MAJ 1 -#define VERSION_MIN 0 -#define VERSION_STR "1.0" +#define VERSION_MIN 1 +#define VERSION_STR "1.1" #define FILE_OPEN_EVENT_WAIT_TIME 3000 // ms @@ -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) @@ -251,11 +264,10 @@ void printVersion() void printUsage() { - printf("Usage: qml [options] [files]\n"); + printf("Usage: qml [options] [files] [-- args]\n"); printf("\n"); - printf("Any argument ending in .qml will be treated as a QML file to be loaded.\n"); + printf("Any unknown argument before '--' will be treated as a QML file to be loaded.\n"); printf("Any number of QML files can be loaded. They will share the same engine.\n"); - printf("Any argument which is not a recognized option and which does not end in .qml will be ignored.\n"); printf("'gui' application type is only available if the QtGui module is available.\n"); printf("'widget' application type is only available if the QtWidgets module is available.\n"); printf("\n"); @@ -388,8 +400,8 @@ int main(int argc, char *argv[]) app->setOrganizationName("QtProject"); app->setOrganizationDomain("qt-project.org"); - qmlRegisterType<Config>("QmlRuntime.Config", VERSION_MAJ, VERSION_MIN, "Configuration"); - qmlRegisterType<PartialScene>("QmlRuntime.Config", VERSION_MAJ, VERSION_MIN, "PartialScene"); + qmlRegisterType<Config>("QmlRuntime.Config", 1, 0, "Configuration"); + qmlRegisterType<PartialScene>("QmlRuntime.Config", 1, 0, "PartialScene"); QQmlApplicationEngine e; QStringList files; QString confFile; @@ -398,7 +410,7 @@ int main(int argc, char *argv[]) //Handle main arguments QStringList argList = app->arguments(); - for (int i = 0; i < argList.count(); i++) { + for (int i = 1; i < argList.count(); i++) { const QString &arg = argList[i]; if (arg == QLatin1String("-quiet")) quietMode = true; @@ -440,9 +452,7 @@ int main(int argc, char *argv[]) dummyDir = argList[i+1]; i++; } else { - //If it ends in .qml, treat it as a file. Else ignore it - if (arg.endsWith(".qml")) - files << arg; + files << arg; } } @@ -486,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()) @@ -518,6 +528,9 @@ int main(int argc, char *argv[]) } } + if (lw->earlyExit) + return 0; + return app->exec(); } diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp index db9d1b9cda..2f6b180090 100644 --- a/tools/qmljs/qmljs.cpp +++ b/tools/qmljs/qmljs.cpp @@ -72,7 +72,7 @@ struct Print: FunctionObject }; V4_OBJECT(FunctionObject) - static ReturnedValue call(Managed *, CallData *callData) + static ReturnedValue call(const Managed *, CallData *callData) { for (int i = 0; i < callData->argc; ++i) { QString s = callData->args[i].toQStringNoThrow(); @@ -98,9 +98,9 @@ struct GC: public FunctionObject }; V4_OBJECT(FunctionObject) - static ReturnedValue call(Managed *m, CallData *) + static ReturnedValue call(const Managed *m, CallData *) { - static_cast<GC *>(m)->engine()->memoryManager->runGC(); + static_cast<const GC *>(m)->engine()->memoryManager->runGC(); return Encode::undefined(); } }; @@ -113,7 +113,7 @@ static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exceptio { QV4::Scope scope(ctx); QV4::ScopedValue ex(scope, exception); - QV4::ErrorObject *e = ex->asErrorObject(); + QV4::ErrorObject *e = ex->as<QV4::ErrorObject>(); if (!e) { std::cerr << "Uncaught exception: " << qPrintable(ex->toQString()) << std::endl; } else { |