From 9fa409cbd90f120132bc2817be2216e2a7c0baba Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Thu, 25 Aug 2011 16:30:36 +0200 Subject: [PATCH] QmlProfiler: manage quick stops before connection Task-number: QTCREATORBUG-5804 Change-Id: I86e9a94c5352d0ac8f9157949afd3b32d60cb05e Reviewed-on: http://codereview.qt.nokia.com/3606 Reviewed-by: Qt Sanity Bot Reviewed-by: Kai Koehne --- src/plugins/qmlprofiler/qml/StatusDisplay.qml | 1 + src/plugins/qmlprofiler/qmlprofilerengine.cpp | 1 + src/plugins/qmlprofiler/qmlprofilertool.cpp | 19 +++++++++++++++++++ src/plugins/qmlprofiler/qmlprofilertool.h | 4 ++++ 4 files changed, 25 insertions(+) diff --git a/src/plugins/qmlprofiler/qml/StatusDisplay.qml b/src/plugins/qmlprofiler/qml/StatusDisplay.qml index 9089e42134a..19a6fcd5b67 100644 --- a/src/plugins/qmlprofiler/qml/StatusDisplay.qml +++ b/src/plugins/qmlprofiler/qml/StatusDisplay.qml @@ -61,6 +61,7 @@ Rectangle { target: statusText text: qsTr("No QML events recorded"); } + onCompleted: root.clearAll(); }, // running app State { diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp index 2f9a1d2baed..b872b878977 100644 --- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp @@ -193,6 +193,7 @@ bool QmlProfilerEngine::start() } AnalyzerManager::handleToolStarted(); + emit starting(this); return true; } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 0dd55faea5a..b883873d2bf 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -106,6 +106,7 @@ public: QToolButton *m_recordButton; QToolButton *m_clearButton; bool m_recordingEnabled; + bool m_appIsRunning; enum ConnectMode { TcpConnection, OstConnection @@ -128,6 +129,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent) d->m_runConfiguration = 0; d->m_isAttached = false; d->m_recordingEnabled = true; + d->m_appIsRunning = false; d->m_connectionTimer.setInterval(200); connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect())); @@ -247,6 +249,9 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(dataReceived())); connect(this, SIGNAL(connectionFailed()), engine, SLOT(finishProcess())); connect(this, SIGNAL(fetchingData(bool)), engine, SLOT(setFetchingData(bool))); + connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)), this, SLOT(setAppIsRunning())); + connect(engine, SIGNAL(finished()), this, SLOT(setAppIsStopped())); + connect(this, SIGNAL(cancelRun()), engine, SLOT(finishProcess())); emit fetchingData(d->m_recordButton->isChecked()); return engine; @@ -395,6 +400,10 @@ void QmlProfilerTool::stopRecording() { d->m_traceWindow->setRecording(false); emit fetchingData(false); + + // manage early stop + if (d->m_client && !d->m_client->isConnected() && d->m_appIsRunning) + emit cancelRun(); } void QmlProfilerTool::setRecording(bool recording) @@ -412,6 +421,16 @@ void QmlProfilerTool::setRecording(bool recording) stopRecording(); } +void QmlProfilerTool::setAppIsRunning() +{ + d->m_appIsRunning = true; +} + +void QmlProfilerTool::setAppIsStopped() +{ + d->m_appIsRunning = false; +} + void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber) { if (lineNumber < 0 || fileUrl.isEmpty()) diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 3164d702ad4..36f5f64e8c2 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -72,6 +72,9 @@ public slots: void stopRecording(); void setRecording(bool recording); + void setAppIsRunning(); + void setAppIsStopped(); + void gotoSourceLocation(const QString &fileUrl, int lineNumber); void updateTimer(qreal elapsedSeconds); void correctTimer(); @@ -84,6 +87,7 @@ signals: void setTimeLabel(const QString &); void fetchingData(bool); void connectionFailed(); + void cancelRun(); private slots: void updateProjectFileList();