forked from qt-creator/qt-creator
QmlProfiler: stop timer on failed connection
Reviewed-by: Kai Koehne
This commit is contained in:
@@ -102,7 +102,6 @@ void QmlProfilerEngine::start()
|
|||||||
|
|
||||||
void QmlProfilerEngine::stop()
|
void QmlProfilerEngine::stop()
|
||||||
{
|
{
|
||||||
d->m_running = false;
|
|
||||||
if (d->m_fetchingData)
|
if (d->m_fetchingData)
|
||||||
emit stopRecording();
|
emit stopRecording();
|
||||||
else
|
else
|
||||||
@@ -116,14 +115,15 @@ void QmlProfilerEngine::spontaneousStop()
|
|||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerEngine::setFetchingData(bool b) {
|
void QmlProfilerEngine::setFetchingData(bool b)
|
||||||
|
{
|
||||||
d->m_fetchingData = b;
|
d->m_fetchingData = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerEngine::finishProcess()
|
void QmlProfilerEngine::finishProcess()
|
||||||
{
|
{
|
||||||
// user stop?
|
if (d->m_running) {
|
||||||
if (!d->m_running) {
|
d->m_running = false;
|
||||||
if (d->m_process) {
|
if (d->m_process) {
|
||||||
disconnect(d->m_process,SIGNAL(finished(int)),this,SLOT(spontaneousStop()));
|
disconnect(d->m_process,SIGNAL(finished(int)),this,SLOT(spontaneousStop()));
|
||||||
if (d->m_process->state() == QProcess::Running) {
|
if (d->m_process->state() == QProcess::Running) {
|
||||||
|
@@ -123,6 +123,7 @@ public:
|
|||||||
bool m_isAttached;
|
bool m_isAttached;
|
||||||
QAction *m_attachAction;
|
QAction *m_attachAction;
|
||||||
QToolButton *m_recordButton;
|
QToolButton *m_recordButton;
|
||||||
|
bool m_recordingEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||||
@@ -135,6 +136,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
|||||||
d->m_runConfiguration = 0;
|
d->m_runConfiguration = 0;
|
||||||
d->m_isAttached = false;
|
d->m_isAttached = false;
|
||||||
d->m_attachAction = 0;
|
d->m_attachAction = 0;
|
||||||
|
d->m_recordingEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerTool::~QmlProfilerTool()
|
QmlProfilerTool::~QmlProfilerTool()
|
||||||
@@ -180,6 +182,7 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
|
|||||||
connect(engine, SIGNAL(finished()), this, SLOT(disconnectClient()));
|
connect(engine, SIGNAL(finished()), this, SLOT(disconnectClient()));
|
||||||
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
|
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
|
||||||
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(finishProcess()));
|
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(finishProcess()));
|
||||||
|
connect(this, SIGNAL(connectionFailed()), engine, SLOT(finishProcess()));
|
||||||
connect(this, SIGNAL(fetchingData(bool)), engine, SLOT(setFetchingData(bool)));
|
connect(this, SIGNAL(fetchingData(bool)), engine, SLOT(setFetchingData(bool)));
|
||||||
emit fetchingData(d->m_recordButton->isChecked());
|
emit fetchingData(d->m_recordButton->isChecked());
|
||||||
|
|
||||||
@@ -292,11 +295,14 @@ void QmlProfilerTool::connectClient()
|
|||||||
d->m_client->waitForConnected();
|
d->m_client->waitForConnected();
|
||||||
|
|
||||||
if (d->m_client->isConnected()) {
|
if (d->m_client->isConnected()) {
|
||||||
|
d->m_traceWindow->setRecording(d->m_recordingEnabled);
|
||||||
if (QmlProfilerPlugin::debugOutput)
|
if (QmlProfilerPlugin::debugOutput)
|
||||||
qWarning("QmlProfiler: connected and running");
|
qWarning("QmlProfiler: connected and running");
|
||||||
} else {
|
} else {
|
||||||
|
d->m_traceWindow->setRecording(false);
|
||||||
if (QmlProfilerPlugin::debugOutput)
|
if (QmlProfilerPlugin::debugOutput)
|
||||||
qWarning("QmlProfiler: Failed to connect: %s", qPrintable(d->m_client->errorString()));
|
qWarning("QmlProfiler: Failed to connect: %s", qPrintable(d->m_client->errorString()));
|
||||||
|
emit connectionFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->m_traceWindow->isRecording())
|
if (d->m_traceWindow->isRecording())
|
||||||
@@ -311,7 +317,6 @@ void QmlProfilerTool::disconnectClient()
|
|||||||
|
|
||||||
void QmlProfilerTool::startRecording()
|
void QmlProfilerTool::startRecording()
|
||||||
{
|
{
|
||||||
d->m_traceWindow->setRecordAtStart(true);
|
|
||||||
if (d->m_client->isConnected()) {
|
if (d->m_client->isConnected()) {
|
||||||
clearDisplay();
|
clearDisplay();
|
||||||
d->m_traceWindow->setRecording(true);
|
d->m_traceWindow->setRecording(true);
|
||||||
@@ -321,14 +326,13 @@ void QmlProfilerTool::startRecording()
|
|||||||
|
|
||||||
void QmlProfilerTool::stopRecording()
|
void QmlProfilerTool::stopRecording()
|
||||||
{
|
{
|
||||||
d->m_traceWindow->setRecordAtStart(d->m_recordButton->isChecked());
|
d->m_traceWindow->setRecording(false);
|
||||||
if (d->m_client->isConnected())
|
|
||||||
d->m_traceWindow->setRecording(false);
|
|
||||||
emit fetchingData(false);
|
emit fetchingData(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::setRecording(bool recording)
|
void QmlProfilerTool::setRecording(bool recording)
|
||||||
{
|
{
|
||||||
|
d->m_recordingEnabled = recording;
|
||||||
if (recording)
|
if (recording)
|
||||||
startRecording();
|
startRecording();
|
||||||
else
|
else
|
||||||
|
@@ -79,6 +79,7 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
void setTimeLabel(const QString &);
|
void setTimeLabel(const QString &);
|
||||||
void fetchingData(bool);
|
void fetchingData(bool);
|
||||||
|
void connectionFailed();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Todo: configurable parameters
|
// Todo: configurable parameters
|
||||||
|
@@ -161,10 +161,14 @@ void TracePlugin::setRecording(bool v)
|
|||||||
{
|
{
|
||||||
if (v == m_recording)
|
if (v == m_recording)
|
||||||
return;
|
return;
|
||||||
QByteArray ba;
|
|
||||||
QDataStream stream(&ba, QIODevice::WriteOnly);
|
if (status() == Enabled) {
|
||||||
stream << v;
|
QByteArray ba;
|
||||||
sendMessage(ba);
|
QDataStream stream(&ba, QIODevice::WriteOnly);
|
||||||
|
stream << v;
|
||||||
|
sendMessage(ba);
|
||||||
|
}
|
||||||
|
|
||||||
m_recording = v;
|
m_recording = v;
|
||||||
emit recordingChanged(v);
|
emit recordingChanged(v);
|
||||||
}
|
}
|
||||||
@@ -262,7 +266,7 @@ void TracePlugin::messageReceived(const QByteArray &data)
|
|||||||
|
|
||||||
TraceWindow::TraceWindow(QWidget *parent)
|
TraceWindow::TraceWindow(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
m_plugin(0), m_recordAtStart(false)
|
m_plugin(0)
|
||||||
{
|
{
|
||||||
setObjectName(tr("Qml Performance Monitor"));
|
setObjectName(tr("Qml Performance Monitor"));
|
||||||
|
|
||||||
@@ -300,8 +304,6 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
|||||||
m_plugin = new TracePlugin(conn);
|
m_plugin = new TracePlugin(conn);
|
||||||
connect(m_plugin,SIGNAL(complete()), this, SIGNAL(viewUpdated()));
|
connect(m_plugin,SIGNAL(complete()), this, SIGNAL(viewUpdated()));
|
||||||
connect(m_plugin,SIGNAL(range(int,qint64,qint64,QStringList,QString,int)),this,SIGNAL(range(int,qint64,qint64,QStringList,QString,int)));
|
connect(m_plugin,SIGNAL(range(int,qint64,qint64,QStringList,QString,int)),this,SIGNAL(range(int,qint64,qint64,QStringList,QString,int)));
|
||||||
if (m_recordAtStart)
|
|
||||||
m_plugin->setRecording(true);
|
|
||||||
|
|
||||||
m_view->rootContext()->setContextProperty("connection", m_plugin);
|
m_view->rootContext()->setContextProperty("connection", m_plugin);
|
||||||
m_view->setSource(QUrl("qrc:/qmlprofiler/MainView.qml"));
|
m_view->setSource(QUrl("qrc:/qmlprofiler/MainView.qml"));
|
||||||
@@ -327,11 +329,6 @@ void TraceWindow::clearDisplay()
|
|||||||
m_plugin->clearView();
|
m_plugin->clearView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceWindow::setRecordAtStart(bool record)
|
|
||||||
{
|
|
||||||
m_recordAtStart = record;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TraceWindow::setRecording(bool recording)
|
void TraceWindow::setRecording(bool recording)
|
||||||
{
|
{
|
||||||
m_plugin->setRecording(recording);
|
m_plugin->setRecording(recording);
|
||||||
|
@@ -63,7 +63,6 @@ public:
|
|||||||
~TraceWindow();
|
~TraceWindow();
|
||||||
|
|
||||||
void reset(QDeclarativeDebugConnection *conn);
|
void reset(QDeclarativeDebugConnection *conn);
|
||||||
void setRecordAtStart(bool record);
|
|
||||||
|
|
||||||
void setRecording(bool recording);
|
void setRecording(bool recording);
|
||||||
bool isRecording() const;
|
bool isRecording() const;
|
||||||
@@ -82,7 +81,6 @@ signals:
|
|||||||
private:
|
private:
|
||||||
TracePlugin *m_plugin;
|
TracePlugin *m_plugin;
|
||||||
QSize m_sizeHint;
|
QSize m_sizeHint;
|
||||||
bool m_recordAtStart;
|
|
||||||
|
|
||||||
QDeclarativeView *m_view;
|
QDeclarativeView *m_view;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user