aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/qmlprofiler/main.cpp20
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp24
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.h2
3 files changed, 30 insertions, 16 deletions
diff --git a/tools/qmlprofiler/main.cpp b/tools/qmlprofiler/main.cpp
index b16706c3a9..2a85b72f1e 100644
--- a/tools/qmlprofiler/main.cpp
+++ b/tools/qmlprofiler/main.cpp
@@ -40,13 +40,15 @@ int main(int argc, char *argv[])
app.parseArguments();
- CommandListener listener;
- QObject::connect(&listener, SIGNAL(command(QString)), &app, SLOT(userCommand(QString)));
- listener.start();
-
- int exitValue = app.exec();
- // wait for listener to exit
- listener.wait();
-
- return exitValue;
+ if (app.isInteractive()) {
+ CommandListener listener;
+ QObject::connect(&listener, SIGNAL(command(QString)), &app, SLOT(userCommand(QString)));
+ listener.start();
+ int exitValue = app.exec();
+ // wait for listener to exit
+ listener.wait();
+ return exitValue;
+ } else {
+ return app.exec();
+ }
}
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 5142999808..eb67b5f40e 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -43,12 +43,9 @@
#include <QtCore/QCommandLineParser>
static const char commandTextC[] =
- "You can control the recoding interactively with the "
- "following commands:\n"
- " r, record\n"
- " Switch recording on or off.\n"
- " q, quit\n"
- " Terminate program.";
+ "The following commands are available:\n"
+ "\"r\", \"record\" Switch recording on or off.\n"
+ "\"q\", \"quit\" Terminate program.";
static const char TraceFileExtension[] = ".qtd";
@@ -62,6 +59,7 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
m_verbose(false),
m_quitAfterSave(false),
m_recording(true),
+ m_interactive(false),
m_qmlProfilerClient(&m_connection),
m_v8profilerClient(&m_connection),
m_connectionAttempts(0),
@@ -134,7 +132,7 @@ void QmlProfilerApplication::parseArguments()
"The QML Profiler retrieves QML tracing data from an application. The data\n"
"collected can then be visualized in Qt Creator. The application to be profiled\n"
"has to enable QML debugging. See the Qt Creator documentation on how to do\n"
- "this for different Qt versions.") + QChar::LineFeed + QChar::LineFeed + tr(commandTextC));
+ "this for different Qt versions."));
QCommandLineOption attach(QStringList() << QLatin1String("a") << QLatin1String("attach"),
tr("Attach to an application already running on <hostname>, "
@@ -155,6 +153,12 @@ void QmlProfilerApplication::parseArguments()
QLatin1String("on|off"), QLatin1String("on"));
parser.addOption(record);
+ QCommandLineOption interactive(QLatin1String("interactive"),
+ tr("Manually control the recording from the command line. The "
+ "profiler will not terminate itself when the application "
+ "does so in this case.") + QChar::Space + tr(commandTextC));
+ parser.addOption(interactive);
+
QCommandLineOption verbose(QStringList() << QLatin1String("verbose"),
tr("Print debugging output."));
parser.addOption(verbose);
@@ -186,6 +190,7 @@ void QmlProfilerApplication::parseArguments()
}
m_recording = (parser.value(record) == QLatin1String("on"));
+ m_interactive = parser.isSet(interactive);
if (parser.isSet(verbose))
m_verbose = true;
@@ -213,6 +218,11 @@ int QmlProfilerApplication::exec()
return QCoreApplication::exec();
}
+bool QmlProfilerApplication::isInteractive() const
+{
+ return m_interactive;
+}
+
void QmlProfilerApplication::printCommands()
{
print(tr(commandTextC));
diff --git a/tools/qmlprofiler/qmlprofilerapplication.h b/tools/qmlprofiler/qmlprofilerapplication.h
index 1b1131e33e..d4af3b0c37 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.h
+++ b/tools/qmlprofiler/qmlprofilerapplication.h
@@ -50,6 +50,7 @@ public:
void parseArguments();
int exec();
+ bool isInteractive() const;
public slots:
void userCommand(const QString &command);
@@ -95,6 +96,7 @@ private:
bool m_verbose;
bool m_quitAfterSave;
bool m_recording;
+ bool m_interactive;
QQmlDebugConnection m_connection;
QmlProfilerClient m_qmlProfilerClient;