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