From 342f684277d07536a0bbdfb63304ee6c16f6ba00 Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Tue, 16 Oct 2012 14:52:35 +0200 Subject: [PATCH] QmlProfiler: Detect interrupted execution Task-number: QTCREATORBUG-8022 The profiler would switch to state "AppKilled" if the connection was cut before all the profiling data could be read. With Qt4.8, however, the application dies before any data is sent at all, and such state would never be reached. This patch fixes the flow of states and properly detects when an application started profiling successfully but dies before delivering the data. If the application doesn't run at all (for example, launching a QtQuick1.1 app from Qt5), the profiler fails gracefully without showing the error dialog. Change-Id: I6fc53127b5dfe41de112e140b77895d430d3f79c Reviewed-by: Kai Koehne --- src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp | 5 +++++ src/plugins/qmlprofiler/qmlprofilerdatamodel.h | 1 + src/plugins/qmlprofiler/qmlprofilertool.cpp | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp index 4dfd866fbe4..642db1bde48 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp @@ -290,6 +290,11 @@ void QmlProfilerDataModel::clear() setState(Empty); } +void QmlProfilerDataModel::prepareForWriting() +{ + setState(AcquiringData); +} + void QmlProfilerDataModel::addRangedEvent(int type, int bindingType, qint64 startTime, qint64 length, const QStringList &data, const QmlDebug::QmlEventLocation &location) diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h index 9ad3b14efab..a39bacaf58c 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h @@ -165,6 +165,7 @@ signals: public slots: void clear(); + void prepareForWriting(); void addRangedEvent(int type, int bindingType, qint64 startTime, qint64 length, const QStringList &data, const QmlDebug::QmlEventLocation &location); void addV8Event(int depth,const QString &function,const QString &filename, int lineNumber, double totalTime, double selfTime); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 9e6a44cfd6b..8b539bfa270 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -692,6 +692,7 @@ void QmlProfilerTool::profilerStateChanged() } case QmlProfilerStateManager::AppKilled : { showNonmodalWarning(tr("Application finished before loading profiled data.\nPlease use the stop button instead.")); + d->m_profilerDataModel->clear(); break; } case QmlProfilerStateManager::Idle : @@ -720,6 +721,7 @@ void QmlProfilerTool::serverRecordingChanged() // clear the old data each time we start a new profiling session if (d->m_profilerState->serverRecording()) { clearData(); + d->m_profilerDataModel->prepareForWriting(); } } }