aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/qmlprofiler/commandlistener.cpp21
-rw-r--r--tools/qmlprofiler/commandlistener.h13
-rw-r--r--tools/qmlprofiler/constants.h4
-rw-r--r--tools/qmlprofiler/main.cpp8
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp12
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.h3
6 files changed, 20 insertions, 41 deletions
diff --git a/tools/qmlprofiler/commandlistener.cpp b/tools/qmlprofiler/commandlistener.cpp
index 1d538d8a3d..369d095725 100644
--- a/tools/qmlprofiler/commandlistener.cpp
+++ b/tools/qmlprofiler/commandlistener.cpp
@@ -35,24 +35,7 @@
#include "constants.h"
#include <QtCore/QTextStream>
-CommandListener::CommandListener(QObject *parent)
- : QThread(parent)
- , m_stopRequested(false)
+void CommandListener::readCommand()
{
-}
-
-void CommandListener::run()
-{
- QString line;
- QTextStream in(stdin, QIODevice::ReadOnly);
- do {
- line = in.readLine();
- line = line.trimmed();
- if (!line.isEmpty()) {
- emit command(line);
- if (line == QLatin1String(Constants::CMD_QUIT)
- || line == QLatin1String(Constants::CMD_QUIT2))
- return;
- }
- } while (!m_stopRequested && !line.isNull());
+ emit command(QTextStream(stdin).readLine());
}
diff --git a/tools/qmlprofiler/commandlistener.h b/tools/qmlprofiler/commandlistener.h
index 7d4d43d727..e74d5323c8 100644
--- a/tools/qmlprofiler/commandlistener.h
+++ b/tools/qmlprofiler/commandlistener.h
@@ -36,20 +36,13 @@
#include <QtCore/QThread>
-class CommandListener : public QThread
-{
+class CommandListener : public QObject {
Q_OBJECT
-public:
- CommandListener(QObject *parent = 0);
+public slots:
+ void readCommand();
- void run();
-
- void requestStop() { m_stopRequested = true; }
signals:
void command(const QString &command);
-
-private:
- bool m_stopRequested;
};
#endif // COMMANDLISTENER_H
diff --git a/tools/qmlprofiler/constants.h b/tools/qmlprofiler/constants.h
index 4e5aac7e32..b925ba00e8 100644
--- a/tools/qmlprofiler/constants.h
+++ b/tools/qmlprofiler/constants.h
@@ -36,10 +36,6 @@
namespace Constants {
-const char CMD_HELP[] ="help";
-const char CMD_HELP2[] = "h";
-const char CMD_HELP3[] = "?";
-
const char CMD_RECORD[] ="record";
const char CMD_RECORD2[] ="r";
diff --git a/tools/qmlprofiler/main.cpp b/tools/qmlprofiler/main.cpp
index 2a85b72f1e..5496072eb2 100644
--- a/tools/qmlprofiler/main.cpp
+++ b/tools/qmlprofiler/main.cpp
@@ -41,12 +41,16 @@ int main(int argc, char *argv[])
app.parseArguments();
if (app.isInteractive()) {
+ QThread listenerThread;
CommandListener listener;
+ listener.moveToThread(&listenerThread);
QObject::connect(&listener, SIGNAL(command(QString)), &app, SLOT(userCommand(QString)));
- listener.start();
+ QObject::connect(&app, SIGNAL(readyForCommand()), &listener, SLOT(readCommand()));
+ listenerThread.start();
int exitValue = app.exec();
+ listenerThread.quit();
// wait for listener to exit
- listener.wait();
+ listenerThread.wait();
return exitValue;
} else {
return app.exec();
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index c2d3375d10..23483b2d16 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -249,14 +249,10 @@ QString QmlProfilerApplication::traceFileName() const
void QmlProfilerApplication::userCommand(const QString &command)
{
QString cmd = command.trimmed();
- if (cmd == Constants::CMD_HELP
- || cmd == Constants::CMD_HELP2
- || cmd == Constants::CMD_HELP3) {
- printCommands();
- } else if (cmd == Constants::CMD_RECORD
- || cmd == Constants::CMD_RECORD2) {
+ if (cmd == Constants::CMD_RECORD || cmd == Constants::CMD_RECORD2) {
m_qmlProfilerClient.sendRecordingStatus(!m_recording);
m_v8profilerClient.sendRecordingStatus(!m_recording);
+ emit readyForCommand();
} else if (cmd == Constants::CMD_QUIT
|| cmd == Constants::CMD_QUIT2) {
print(QLatin1String("Quit"));
@@ -267,6 +263,9 @@ void QmlProfilerApplication::userCommand(const QString &command)
} else {
quit();
}
+ } else {
+ printCommands();
+ emit readyForCommand();
}
}
@@ -300,6 +299,7 @@ void QmlProfilerApplication::run()
}
m_connectTimer.start();
+ emit readyForCommand();
}
void QmlProfilerApplication::tryToConnect()
diff --git a/tools/qmlprofiler/qmlprofilerapplication.h b/tools/qmlprofiler/qmlprofilerapplication.h
index d4af3b0c37..8d2cbffe7b 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.h
+++ b/tools/qmlprofiler/qmlprofilerapplication.h
@@ -52,6 +52,9 @@ public:
int exec();
bool isInteractive() const;
+signals:
+ void readyForCommand();
+
public slots:
void userCommand(const QString &command);
void notifyTraceStarted();