diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp index 27f34056ff5..c0b1133700f 100644 --- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp @@ -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(); diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp index dc75dd5cb85..b1856168883 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp @@ -125,11 +125,16 @@ void QmlProfilerEventStatistics::clear() d->m_rootHash.clear(); } -QList QmlProfilerEventStatistics::getEventList() +QList 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) { diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.h b/src/plugins/qmlprofiler/qmlprofilereventview.h index eac510a9e24..857c5058ae8 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.h +++ b/src/plugins/qmlprofiler/qmlprofilereventview.h @@ -85,7 +85,8 @@ public: explicit QmlProfilerEventStatistics(QObject *parent = 0); ~QmlProfilerEventStatistics(); - QmlEventList getEventList(); + QmlEventList getEventList() const; + int eventCount() const; signals: void dataReady(); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 18c14c20955..a72872bce04 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -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); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index c4520d5a65f..490bbd26504 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -72,6 +72,7 @@ public slots: void gotoSourceLocation(const QString &fileUrl, int lineNumber); void updateTimer(qreal elapsedSeconds); + void correctTimer(); void clearDisplay();