forked from qt-creator/qt-creator
QmlProfiler: Simplify application state handling
Only half of the states are useful for anything. Change-Id: I4591ccda6eec902e929e07947bad6c3f7b967ef9 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
@@ -340,7 +340,7 @@ void QmlProfilerClientManager::profilerStateChanged()
|
|||||||
if (d->qmlclientplugin)
|
if (d->qmlclientplugin)
|
||||||
d->qmlclientplugin.data()->setRecording(false);
|
d->qmlclientplugin.data()->setRecording(false);
|
||||||
} else {
|
} else {
|
||||||
d->profilerState->setCurrentState(QmlProfilerStateManager::AppReadyToStop);
|
d->profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -351,10 +351,8 @@ void QmlProfilerClientManager::profilerStateChanged()
|
|||||||
void QmlProfilerClientManager::clientRecordingChanged()
|
void QmlProfilerClientManager::clientRecordingChanged()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->profilerState, return);
|
QTC_ASSERT(d->profilerState, return);
|
||||||
if (d->profilerState->currentState() == QmlProfilerStateManager::AppRunning) {
|
|
||||||
if (d->qmlclientplugin)
|
if (d->qmlclientplugin)
|
||||||
d->qmlclientplugin.data()->setRecording(d->profilerState->clientRecording());
|
d->qmlclientplugin->setRecording(d->profilerState->clientRecording());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ QmlProfilerRunControl::QmlProfilerRunControl(const AnalyzerStartParameters &sp,
|
|||||||
|
|
||||||
QmlProfilerRunControl::~QmlProfilerRunControl()
|
QmlProfilerRunControl::~QmlProfilerRunControl()
|
||||||
{
|
{
|
||||||
if (d->m_profilerState && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning)
|
if (d->m_profilerState)
|
||||||
stopEngine();
|
stopEngine();
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
@@ -110,15 +110,13 @@ bool QmlProfilerRunControl::startEngine()
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(d->m_profilerState, return false);
|
QTC_ASSERT(d->m_profilerState, return false);
|
||||||
|
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStarting);
|
|
||||||
|
|
||||||
if (startParameters().analyzerPort != 0)
|
if (startParameters().analyzerPort != 0)
|
||||||
emit processRunning(startParameters().analyzerPort);
|
emit processRunning(startParameters().analyzerPort);
|
||||||
else
|
else
|
||||||
d->m_noDebugOutputTimer.start();
|
d->m_noDebugOutputTimer.start();
|
||||||
|
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
|
||||||
engineStarted();
|
emit starting(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,10 +129,7 @@ void QmlProfilerRunControl::stopEngine()
|
|||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopRequested);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopRequested);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QmlProfilerStateManager::AppReadyToStop : {
|
case QmlProfilerStateManager::Idle:
|
||||||
cancelProcess();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case QmlProfilerStateManager::AppDying:
|
case QmlProfilerStateManager::AppDying:
|
||||||
// valid, but no further action is needed
|
// valid, but no further action is needed
|
||||||
break;
|
break;
|
||||||
@@ -152,22 +147,17 @@ void QmlProfilerRunControl::notifyRemoteFinished()
|
|||||||
QTC_ASSERT(d->m_profilerState, return);
|
QTC_ASSERT(d->m_profilerState, return);
|
||||||
|
|
||||||
switch (d->m_profilerState->currentState()) {
|
switch (d->m_profilerState->currentState()) {
|
||||||
case QmlProfilerStateManager::AppRunning : {
|
case QmlProfilerStateManager::AppRunning:
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
||||||
AnalyzerManager::stopTool();
|
AnalyzerManager::stopTool();
|
||||||
|
emit finished();
|
||||||
runControlFinished();
|
|
||||||
break;
|
break;
|
||||||
}
|
case QmlProfilerStateManager::Idle:
|
||||||
case QmlProfilerStateManager::AppStopped :
|
|
||||||
case QmlProfilerStateManager::AppKilled :
|
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
|
||||||
break;
|
break;
|
||||||
default: {
|
default:
|
||||||
const QString message = QString::fromLatin1("Process died unexpectedly from state %1 in %2:%3")
|
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__));
|
.arg(d->m_profilerState->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
||||||
qWarning("%s", qPrintable(message));
|
qWarning("%s", qPrintable(message));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,14 +167,11 @@ void QmlProfilerRunControl::cancelProcess()
|
|||||||
QTC_ASSERT(d->m_profilerState, return);
|
QTC_ASSERT(d->m_profilerState, return);
|
||||||
|
|
||||||
switch (d->m_profilerState->currentState()) {
|
switch (d->m_profilerState->currentState()) {
|
||||||
case QmlProfilerStateManager::AppReadyToStop : {
|
case QmlProfilerStateManager::Idle:
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopped);
|
|
||||||
break;
|
break;
|
||||||
}
|
case QmlProfilerStateManager::AppRunning:
|
||||||
case QmlProfilerStateManager::AppRunning : {
|
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default: {
|
default: {
|
||||||
const QString message = QString::fromLatin1("Unexpected process termination requested with state %1 in %2:%3")
|
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__));
|
.arg(d->m_profilerState->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
||||||
@@ -192,7 +179,7 @@ void QmlProfilerRunControl::cancelProcess()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runControlFinished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerRunControl::logApplicationMessage(const QString &msg, Utils::OutputFormat format)
|
void QmlProfilerRunControl::logApplicationMessage(const QString &msg, Utils::OutputFormat format)
|
||||||
@@ -221,7 +208,7 @@ void QmlProfilerRunControl::wrongSetupMessageBox(const QString &errorMessage)
|
|||||||
// KILL
|
// KILL
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
||||||
AnalyzerManager::stopTool();
|
AnalyzerManager::stopTool();
|
||||||
runControlFinished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerRunControl::wrongSetupMessageBoxFinished(int button)
|
void QmlProfilerRunControl::wrongSetupMessageBoxFinished(int button)
|
||||||
@@ -248,18 +235,6 @@ void QmlProfilerRunControl::processIsRunning(quint16 port)
|
|||||||
emit processRunning(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 )
|
void QmlProfilerRunControl::registerProfilerStateManager( QmlProfilerStateManager *profilerState )
|
||||||
{
|
{
|
||||||
// disconnect old
|
// disconnect old
|
||||||
@@ -276,15 +251,10 @@ void QmlProfilerRunControl::registerProfilerStateManager( QmlProfilerStateManage
|
|||||||
void QmlProfilerRunControl::profilerStateChanged()
|
void QmlProfilerRunControl::profilerStateChanged()
|
||||||
{
|
{
|
||||||
switch (d->m_profilerState->currentState()) {
|
switch (d->m_profilerState->currentState()) {
|
||||||
case QmlProfilerStateManager::AppReadyToStop : {
|
case QmlProfilerStateManager::Idle:
|
||||||
if (d->m_running)
|
emit finished();
|
||||||
cancelProcess();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case QmlProfilerStateManager::Idle : {
|
|
||||||
d->m_noDebugOutputTimer.stop();
|
d->m_noDebugOutputTimer.stop();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ private slots:
|
|||||||
void wrongSetupMessageBox(const QString &errorMessage);
|
void wrongSetupMessageBox(const QString &errorMessage);
|
||||||
void wrongSetupMessageBoxFinished(int);
|
void wrongSetupMessageBoxFinished(int);
|
||||||
void processIsRunning(quint16 port = 0);
|
void processIsRunning(quint16 port = 0);
|
||||||
void engineStarted();
|
|
||||||
void runControlFinished();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void profilerStateChanged();
|
void profilerStateChanged();
|
||||||
|
|||||||
@@ -41,13 +41,9 @@ namespace QmlProfiler {
|
|||||||
inline QString stringForState(int state) {
|
inline QString stringForState(int state) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case QmlProfilerStateManager::Idle: return QLatin1String("Idle");
|
case QmlProfilerStateManager::Idle: return QLatin1String("Idle");
|
||||||
case QmlProfilerStateManager::AppStarting: return QLatin1String("AppStarting");
|
|
||||||
case QmlProfilerStateManager::AppRunning: return QLatin1String("AppRunning");
|
case QmlProfilerStateManager::AppRunning: return QLatin1String("AppRunning");
|
||||||
case QmlProfilerStateManager::AppStopRequested: return QLatin1String("AppStopRequested");
|
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::AppDying: return QLatin1String("AppDying");
|
||||||
case QmlProfilerStateManager::AppKilled: return QLatin1String("AppKilled");
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
@@ -120,40 +116,22 @@ void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
|
|||||||
QTC_ASSERT(d->m_currentState != newState, /**/);
|
QTC_ASSERT(d->m_currentState != newState, /**/);
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case Idle:
|
case Idle:
|
||||||
QTC_ASSERT(d->m_currentState == AppStarting ||
|
QTC_ASSERT(d->m_currentState == AppStopRequested ||
|
||||||
d->m_currentState == AppStopped ||
|
d->m_currentState == AppDying,
|
||||||
d->m_currentState == AppKilled,
|
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
|
||||||
break;
|
|
||||||
case AppStarting:
|
|
||||||
QTC_ASSERT(d->m_currentState == Idle,
|
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << stringForState(d->m_currentState));
|
||||||
break;
|
break;
|
||||||
case AppRunning:
|
case AppRunning:
|
||||||
QTC_ASSERT(d->m_currentState == AppStarting,
|
QTC_ASSERT(d->m_currentState == Idle,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << stringForState(d->m_currentState));
|
||||||
break;
|
break;
|
||||||
case AppStopRequested:
|
case AppStopRequested:
|
||||||
QTC_ASSERT(d->m_currentState == AppRunning,
|
QTC_ASSERT(d->m_currentState == AppRunning,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << stringForState(d->m_currentState));
|
||||||
break;
|
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:
|
case AppDying:
|
||||||
QTC_ASSERT(d->m_currentState == AppRunning,
|
QTC_ASSERT(d->m_currentState == AppRunning,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << stringForState(d->m_currentState));
|
||||||
break;
|
break;
|
||||||
case AppKilled:
|
|
||||||
QTC_ASSERT(d->m_currentState == AppDying,
|
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
|
||||||
break;
|
|
||||||
default: {
|
default: {
|
||||||
const QString message = QString::fromLatin1("Switching to unknown state in %1:%2").arg(QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
const QString message = QString::fromLatin1("Switching to unknown state in %1:%2").arg(QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
||||||
qWarning("%s", qPrintable(message));
|
qWarning("%s", qPrintable(message));
|
||||||
|
|||||||
@@ -41,13 +41,9 @@ class QmlProfilerStateManager : public QObject
|
|||||||
public:
|
public:
|
||||||
enum QmlProfilerState {
|
enum QmlProfilerState {
|
||||||
Idle,
|
Idle,
|
||||||
AppStarting,
|
|
||||||
AppRunning,
|
AppRunning,
|
||||||
AppStopRequested,
|
AppStopRequested,
|
||||||
AppReadyToStop,
|
|
||||||
AppStopped,
|
|
||||||
AppDying,
|
AppDying,
|
||||||
AppKilled
|
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit QmlProfilerStateManager(QObject *parent = 0);
|
explicit QmlProfilerStateManager(QObject *parent = 0);
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ void QmlProfilerStateWidget::updateDisplay()
|
|||||||
}
|
}
|
||||||
} else if (d->m_modelManager->progress() != 0 && !d->m_modelManager->isEmpty()) {
|
} else if (d->m_modelManager->progress() != 0 && !d->m_modelManager->isEmpty()) {
|
||||||
// When datamodel is acquiring data
|
// When datamodel is acquiring data
|
||||||
if (d->m_profilerState->currentState() != QmlProfilerStateManager::AppKilled)
|
if (d->m_profilerState->currentState() != QmlProfilerStateManager::Idle)
|
||||||
showText(tr("Loading data"), true);
|
showText(tr("Loading data"), true);
|
||||||
else // Application died before all data could be read
|
else // Application died before all data could be read
|
||||||
showText(tr("Application stopped before loading all data"), true);
|
showText(tr("Application stopped before loading all data"), true);
|
||||||
|
|||||||
@@ -609,10 +609,11 @@ void QmlProfilerTool::clientsDisconnected()
|
|||||||
{
|
{
|
||||||
// If the application stopped by itself, check if we have all the data
|
// If the application stopped by itself, check if we have all the data
|
||||||
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying) {
|
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying) {
|
||||||
if (d->m_profilerModelManager->state() == QmlProfilerModelManager::AcquiringData)
|
if (d->m_profilerModelManager->state() == QmlProfilerModelManager::AcquiringData) {
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
|
showNonmodalWarning(tr("Application finished before loading profiled data.\n"
|
||||||
else
|
"Please use the stop button instead."));
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopped);
|
d->m_profilerModelManager->clear();
|
||||||
|
}
|
||||||
|
|
||||||
// ... and return to the "base" state
|
// ... and return to the "base" state
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
||||||
@@ -679,7 +680,7 @@ void QmlProfilerTool::profilerDataModelStateChanged()
|
|||||||
break;
|
break;
|
||||||
case QmlProfilerModelManager::Done :
|
case QmlProfilerModelManager::Done :
|
||||||
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppStopRequested)
|
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppStopRequested)
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppReadyToStop);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
||||||
showSaveOption();
|
showSaveOption();
|
||||||
updateTimeDisplay();
|
updateTimeDisplay();
|
||||||
restoreFeatureVisibility();
|
restoreFeatureVisibility();
|
||||||
@@ -727,11 +728,6 @@ void QmlProfilerTool::profilerStateChanged()
|
|||||||
QTimer::singleShot(0, this, SLOT(clientsDisconnected()));
|
QTimer::singleShot(0, this, SLOT(clientsDisconnected()));
|
||||||
break;
|
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 :
|
case QmlProfilerStateManager::Idle :
|
||||||
// when the app finishes, set recording display to client status
|
// when the app finishes, set recording display to client status
|
||||||
setRecording(d->m_profilerState->clientRecording());
|
setRecording(d->m_profilerState->clientRecording());
|
||||||
|
|||||||
Reference in New Issue
Block a user