QmlProfiler: display warning when app killed

Change-Id: I2183e02a5ce4b266702d0771933bda61efa66e95
Reviewed-on: http://codereview.qt.nokia.com/1603
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
This commit is contained in:
Christiaan Janssen
2011-07-13 14:47:34 +02:00
committed by Aurindam Jana
parent b533cea366
commit 82ff204314
5 changed files with 30 additions and 3 deletions

View File

@@ -173,6 +173,19 @@ void QmlProfilerEngine::stop()
void QmlProfilerEngine::stopped()
{
// user feedback
if (d->m_running && d->m_fetchingData) {
Core::ICore * const core = Core::ICore::instance();
QMessageBox *killedWarning = new QMessageBox(core->mainWindow());
killedWarning->setIcon(QMessageBox::Warning);
killedWarning->setWindowTitle(tr("QML Profiler"));
killedWarning->setText(tr("Application finished before loading profiled data.\n Please use the stop button instead."));
killedWarning->setStandardButtons(QMessageBox::Ok);
killedWarning->setDefaultButton(QMessageBox::Ok);
killedWarning->setModal(false);
killedWarning->show();
}
d->m_running = false;
AnalyzerManager::stopTool(); // FIXME: Needed?
emit finished();

View File

@@ -125,11 +125,16 @@ void QmlProfilerEventStatistics::clear()
d->m_rootHash.clear();
}
QList <QmlEventData *> QmlProfilerEventStatistics::getEventList()
QList <QmlEventData *> QmlProfilerEventStatistics::getEventList() const
{
return d->m_rootHash.values();
}
int QmlProfilerEventStatistics::eventCount() const
{
return d->m_rootHash.size();
}
void QmlProfilerEventStatistics::addRangedEvent(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length,
const QStringList &data, const QString &fileName, int line)
{

View File

@@ -85,7 +85,8 @@ public:
explicit QmlProfilerEventStatistics(QObject *parent = 0);
~QmlProfilerEventStatistics();
QmlEventList getEventList();
QmlEventList getEventList() const;
int eventCount() const;
signals:
void dataReady();

View File

@@ -217,6 +217,7 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
connect(engine, SIGNAL(processRunning(int)), this, SLOT(connectClient(int)));
connect(engine, SIGNAL(finished()), this, SLOT(disconnectClient()));
connect(engine, SIGNAL(finished()), this, SLOT(correctTimer()));
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(dataReceived()));
connect(this, SIGNAL(connectionFailed()), engine, SLOT(finishProcess()));
@@ -335,8 +336,9 @@ QWidget *QmlProfilerTool::createWidgets()
palette.setColor(QPalette::WindowText, Qt::white);
timeLabel->setPalette(palette);
timeLabel->setIndent(10);
connect(d->m_traceWindow, SIGNAL(viewUpdated()), this, SLOT(correctTimer()));
connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
correctTimer();
layout->addWidget(timeLabel);
toolbarWidget->setLayout(layout);
@@ -432,6 +434,11 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber)
}
}
void QmlProfilerTool::correctTimer() {
if (d->m_statistics->eventCount() == 0)
updateTimer(0);
}
void QmlProfilerTool::updateTimer(qreal elapsedSeconds)
{
QString timeString = QString::number(elapsedSeconds,'f',1);

View File

@@ -72,6 +72,7 @@ public slots:
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
void updateTimer(qreal elapsedSeconds);
void correctTimer();
void clearDisplay();