aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlprofiler/main.cpp
blob: e89eecbef28ca2b51d5e1da14e332e5674e27e02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "commandlistener.h"
#include "qmlprofilerapplication.h"

int main(int argc, char *argv[])
{
    QmlProfilerApplication app(argc, argv);

    app.parseArguments();

    if (app.isInteractive()) {
        QThread listenerThread;
        CommandListener listener;
        listener.moveToThread(&listenerThread);
        QObject::connect(&listener, &CommandListener::command,
                         &app, &QmlProfilerApplication::userCommand);
        QObject::connect(&app, &QmlProfilerApplication::readyForCommand,
                         &listener, &CommandListener::readCommand);
        listenerThread.start();
        int exitValue = app.exec();
        listenerThread.quit();
        // wait for listener to exit
        listenerThread.wait();
        return exitValue;
    } else {
        int exitValue = app.exec();
        app.outputData();
        return exitValue;
    }
}