diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp index 670b20ceb4e..3a1343f6f1a 100644 --- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp @@ -340,7 +340,7 @@ void QmlProfilerClientManager::profilerStateChanged() if (d->qmlclientplugin) d->qmlclientplugin.data()->setRecording(false); } else { - d->profilerState->setCurrentState(QmlProfilerStateManager::AppReadyToStop); + d->profilerState->setCurrentState(QmlProfilerStateManager::Idle); } break; default: @@ -351,10 +351,8 @@ void QmlProfilerClientManager::profilerStateChanged() void QmlProfilerClientManager::clientRecordingChanged() { QTC_ASSERT(d->profilerState, return); - if (d->profilerState->currentState() == QmlProfilerStateManager::AppRunning) { - if (d->qmlclientplugin) - d->qmlclientplugin.data()->setRecording(d->profilerState->clientRecording()); - } + if (d->qmlclientplugin) + d->qmlclientplugin->setRecording(d->profilerState->clientRecording()); } } // namespace Internal diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index e6e5303c4c1..62d93db3ae3 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -101,7 +101,7 @@ QmlProfilerRunControl::QmlProfilerRunControl(const AnalyzerStartParameters &sp, QmlProfilerRunControl::~QmlProfilerRunControl() { - if (d->m_profilerState && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) + if (d->m_profilerState) stopEngine(); delete d; } @@ -110,15 +110,13 @@ bool QmlProfilerRunControl::startEngine() { QTC_ASSERT(d->m_profilerState, return false); - d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStarting); - if (startParameters().analyzerPort != 0) emit processRunning(startParameters().analyzerPort); else d->m_noDebugOutputTimer.start(); d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning); - engineStarted(); + emit starting(this); return true; } @@ -131,11 +129,8 @@ void QmlProfilerRunControl::stopEngine() d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopRequested); break; } - case QmlProfilerStateManager::AppReadyToStop : { - cancelProcess(); - break; - } - case QmlProfilerStateManager::AppDying : + case QmlProfilerStateManager::Idle: + case QmlProfilerStateManager::AppDying: // valid, but no further action is needed break; default: { @@ -152,22 +147,17 @@ void QmlProfilerRunControl::notifyRemoteFinished() QTC_ASSERT(d->m_profilerState, return); switch (d->m_profilerState->currentState()) { - case QmlProfilerStateManager::AppRunning : { + case QmlProfilerStateManager::AppRunning: d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying); AnalyzerManager::stopTool(); - - runControlFinished(); + emit finished(); break; - } - case QmlProfilerStateManager::AppStopped : - case QmlProfilerStateManager::AppKilled : - d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); + case QmlProfilerStateManager::Idle: break; - default: { + default: const QString message = QString::fromLatin1("Process died unexpectedly from state %1 in %2:%3") .arg(d->m_profilerState->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__)); qWarning("%s", qPrintable(message)); -} break; } } @@ -177,14 +167,11 @@ void QmlProfilerRunControl::cancelProcess() QTC_ASSERT(d->m_profilerState, return); switch (d->m_profilerState->currentState()) { - case QmlProfilerStateManager::AppReadyToStop : { - d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopped); + case QmlProfilerStateManager::Idle: break; - } - case QmlProfilerStateManager::AppRunning : { + case QmlProfilerStateManager::AppRunning: d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying); break; - } default: { const QString message = QString::fromLatin1("Unexpected process termination requested with state %1 in %2:%3") .arg(d->m_profilerState->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__)); @@ -192,7 +179,7 @@ void QmlProfilerRunControl::cancelProcess() return; } } - runControlFinished(); + emit finished(); } void QmlProfilerRunControl::logApplicationMessage(const QString &msg, Utils::OutputFormat format) @@ -221,7 +208,7 @@ void QmlProfilerRunControl::wrongSetupMessageBox(const QString &errorMessage) // KILL d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying); AnalyzerManager::stopTool(); - runControlFinished(); + emit finished(); } void QmlProfilerRunControl::wrongSetupMessageBoxFinished(int button) @@ -248,18 +235,6 @@ void QmlProfilerRunControl::processIsRunning(quint16 port) emit processRunning(port); } -void QmlProfilerRunControl::engineStarted() -{ - d->m_running = true; - emit starting(this); -} - -void QmlProfilerRunControl::runControlFinished() -{ - d->m_running = false; - emit finished(); -} - void QmlProfilerRunControl::registerProfilerStateManager( QmlProfilerStateManager *profilerState ) { // disconnect old @@ -276,15 +251,10 @@ void QmlProfilerRunControl::registerProfilerStateManager( QmlProfilerStateManage void QmlProfilerRunControl::profilerStateChanged() { switch (d->m_profilerState->currentState()) { - case QmlProfilerStateManager::AppReadyToStop : { - if (d->m_running) - cancelProcess(); - break; - } - case QmlProfilerStateManager::Idle : { + case QmlProfilerStateManager::Idle: + emit finished(); d->m_noDebugOutputTimer.stop(); break; - } default: break; } diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h index b7a575586b7..812d660d623 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h @@ -67,8 +67,6 @@ private slots: void wrongSetupMessageBox(const QString &errorMessage); void wrongSetupMessageBoxFinished(int); void processIsRunning(quint16 port = 0); - void engineStarted(); - void runControlFinished(); private slots: void profilerStateChanged(); diff --git a/src/plugins/qmlprofiler/qmlprofilerstatemanager.cpp b/src/plugins/qmlprofiler/qmlprofilerstatemanager.cpp index 09e0e6b8d65..f01aab6dca2 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatemanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatemanager.cpp @@ -41,13 +41,9 @@ namespace QmlProfiler { inline QString stringForState(int state) { switch (state) { case QmlProfilerStateManager::Idle: return QLatin1String("Idle"); - case QmlProfilerStateManager::AppStarting: return QLatin1String("AppStarting"); case QmlProfilerStateManager::AppRunning: return QLatin1String("AppRunning"); case QmlProfilerStateManager::AppStopRequested: return QLatin1String("AppStopRequested"); - case QmlProfilerStateManager::AppReadyToStop: return QLatin1String("AppReadyToStop"); - case QmlProfilerStateManager::AppStopped: return QLatin1String("AppStopped"); case QmlProfilerStateManager::AppDying: return QLatin1String("AppDying"); - case QmlProfilerStateManager::AppKilled: return QLatin1String("AppKilled"); default: break; } return QString(); @@ -120,40 +116,22 @@ void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState) QTC_ASSERT(d->m_currentState != newState, /**/); switch (newState) { case Idle: - QTC_ASSERT(d->m_currentState == AppStarting || - d->m_currentState == AppStopped || - d->m_currentState == AppKilled, - qDebug() << "from" << stringForState(d->m_currentState)); - break; - case AppStarting: - QTC_ASSERT(d->m_currentState == Idle, + QTC_ASSERT(d->m_currentState == AppStopRequested || + d->m_currentState == AppDying, qDebug() << "from" << stringForState(d->m_currentState)); break; case AppRunning: - QTC_ASSERT(d->m_currentState == AppStarting, + QTC_ASSERT(d->m_currentState == Idle, qDebug() << "from" << stringForState(d->m_currentState)); break; case AppStopRequested: QTC_ASSERT(d->m_currentState == AppRunning, qDebug() << "from" << stringForState(d->m_currentState)); break; - case AppReadyToStop: - QTC_ASSERT(d->m_currentState == AppStopRequested, - qDebug() << "from" << stringForState(d->m_currentState)); - break; - case AppStopped: - QTC_ASSERT(d->m_currentState == AppReadyToStop || - d->m_currentState == AppDying, - qDebug() << "from" << stringForState(d->m_currentState)); - break; case AppDying: QTC_ASSERT(d->m_currentState == AppRunning, qDebug() << "from" << stringForState(d->m_currentState)); break; - case AppKilled: - QTC_ASSERT(d->m_currentState == AppDying, - qDebug() << "from" << stringForState(d->m_currentState)); - break; default: { const QString message = QString::fromLatin1("Switching to unknown state in %1:%2").arg(QString::fromLatin1(__FILE__), QString::number(__LINE__)); qWarning("%s", qPrintable(message)); diff --git a/src/plugins/qmlprofiler/qmlprofilerstatemanager.h b/src/plugins/qmlprofiler/qmlprofilerstatemanager.h index da6fa149742..790fc8be437 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatemanager.h +++ b/src/plugins/qmlprofiler/qmlprofilerstatemanager.h @@ -41,13 +41,9 @@ class QmlProfilerStateManager : public QObject public: enum QmlProfilerState { Idle, - AppStarting, AppRunning, AppStopRequested, - AppReadyToStop, - AppStopped, AppDying, - AppKilled }; explicit QmlProfilerStateManager(QObject *parent = 0); diff --git a/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp index 7290b710698..5b1bd1c7232 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp @@ -203,7 +203,7 @@ void QmlProfilerStateWidget::updateDisplay() } } else if (d->m_modelManager->progress() != 0 && !d->m_modelManager->isEmpty()) { // When datamodel is acquiring data - if (d->m_profilerState->currentState() != QmlProfilerStateManager::AppKilled) + if (d->m_profilerState->currentState() != QmlProfilerStateManager::Idle) showText(tr("Loading data"), true); else // Application died before all data could be read showText(tr("Application stopped before loading all data"), true); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 36f7ddfcd31..c0eb1ef9d37 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -609,10 +609,11 @@ void QmlProfilerTool::clientsDisconnected() { // If the application stopped by itself, check if we have all the data if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying) { - if (d->m_profilerModelManager->state() == QmlProfilerModelManager::AcquiringData) - d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled); - else - d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopped); + if (d->m_profilerModelManager->state() == QmlProfilerModelManager::AcquiringData) { + showNonmodalWarning(tr("Application finished before loading profiled data.\n" + "Please use the stop button instead.")); + d->m_profilerModelManager->clear(); + } // ... and return to the "base" state d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); @@ -679,7 +680,7 @@ void QmlProfilerTool::profilerDataModelStateChanged() break; case QmlProfilerModelManager::Done : if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppStopRequested) - d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppReadyToStop); + d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); showSaveOption(); updateTimeDisplay(); restoreFeatureVisibility(); @@ -727,11 +728,6 @@ void QmlProfilerTool::profilerStateChanged() QTimer::singleShot(0, this, SLOT(clientsDisconnected())); break; } - case QmlProfilerStateManager::AppKilled : { - showNonmodalWarning(tr("Application finished before loading profiled data.\nPlease use the stop button instead.")); - d->m_profilerModelManager->clear(); - break; - } case QmlProfilerStateManager::Idle : // when the app finishes, set recording display to client status setRecording(d->m_profilerState->clientRecording());