diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index b810a785303..33d0763aa69 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -176,6 +176,7 @@ Rectangle { function clearAll() { clearDisplay(); + elapsedTime = 0; } function nextEvent() { diff --git a/src/plugins/qmlprofiler/qml/StatusDisplay.qml b/src/plugins/qmlprofiler/qml/StatusDisplay.qml index 8919d07b139..8a434f83565 100644 --- a/src/plugins/qmlprofiler/qml/StatusDisplay.qml +++ b/src/plugins/qmlprofiler/qml/StatusDisplay.qml @@ -69,7 +69,7 @@ Item { states: [ // no data available State { - when: (root.eventCount == 0) && !root.recordingEnabled + when: (root.eventCount == 0) && (elapsedTime > 0) && !root.recordingEnabled PropertyChanges { target: statusDisplay visible: true diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp index 3f950e9d3f7..6712522aeb5 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp @@ -800,6 +800,8 @@ void QmlProfilerDataModel::complete() d->postProcess(); } else if (currentState() == Empty) { + d->v8DataModel->collectV8Statistics(); + compileStatistics(traceStartTime(), traceEndTime()); setState(Done); } else { emit error("Unexpected complete signal in data model"); @@ -819,7 +821,6 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::postProcess() q->reloadDetails(); prepareForDisplay(); q->compileStatistics(q->traceStartTime(), q->traceEndTime()); - } q->setState(Done); } @@ -1063,9 +1064,18 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::linkEndsToStarts() void QmlProfilerDataModel::compileStatistics(qint64 startTime, qint64 endTime) { d->clearStatistics(); - d->redoTree(startTime, endTime); - d->computeMedianTime(startTime, endTime); - d->findBindingLoops(startTime, endTime); + if (traceDuration() > 0) { + if (count() > 0) { + d->redoTree(startTime, endTime); + d->computeMedianTime(startTime, endTime); + d->findBindingLoops(startTime, endTime); + } else { + d->insertQmlRootEvent(); + QmlRangeEventData *listedRootEvent = d->rangeEventDictionary.value(rootEventName()); + listedRootEvent->calls = 1; + listedRootEvent->percentOfTime = 100; + } + } } void QmlProfilerDataModel::QmlProfilerDataModelPrivate::clearStatistics() @@ -1074,7 +1084,7 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::clearStatistics() foreach (QmlRangeEventData *eventDescription, rangeEventDictionary.values()) { eventDescription->calls = 0; // maximum possible value - eventDescription->minTime = endInstanceList.last().endTime; + eventDescription->minTime = traceEndTime; eventDescription->maxTime = 0; eventDescription->medianTime = 0; eventDescription->duration = 0; @@ -1661,10 +1671,6 @@ void QmlProfilerDataModel::setState(QmlProfilerDataModel::State state) d->listState = state; emit stateChanged(); - // special: if we were done with an empty list, clean internal data and go back to empty - if (d->listState == Done && isEmpty()) { - clear(); - } return; } diff --git a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp index d1f7da117da..3ee6d60a68e 100644 --- a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp @@ -237,6 +237,15 @@ void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::collectV8Statistics() v8event->eventId = index++; } v8RootEvent.eventId = v8EventHash[rootEventHash]->eventId; + } else { + // On empty data, still add a fake root event + clearV8RootEvent(); + v8RootEvent.totalPercent = 100; + QString rootEventHash = QmlProfilerDataModel::getHashStringForV8Event( + QmlProfilerDataModel::rootEventName(), + QmlProfilerDataModel::rootEventDescription()); + v8EventHash[rootEventHash] = new QV8EventData; + *v8EventHash[rootEventHash] = v8RootEvent; } } diff --git a/src/plugins/qmlprofiler/timelinerenderer.cpp b/src/plugins/qmlprofiler/timelinerenderer.cpp index 276f341d258..4574fe6ee26 100644 --- a/src/plugins/qmlprofiler/timelinerenderer.cpp +++ b/src/plugins/qmlprofiler/timelinerenderer.cpp @@ -109,9 +109,11 @@ void TimelineRenderer::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid int firstIndex = m_profilerDataModel->findFirstIndex(m_startTime); int lastIndex = m_profilerDataModel->findLastIndex(m_endTime); - drawItemsToPainter(p, firstIndex, lastIndex); - drawSelectionBoxes(p, firstIndex, lastIndex); - drawBindingLoopMarkers(p, firstIndex, lastIndex); + if (lastIndex < m_profilerDataModel->count()) { + drawItemsToPainter(p, firstIndex, lastIndex); + drawSelectionBoxes(p, firstIndex, lastIndex); + drawBindingLoopMarkers(p, firstIndex, lastIndex); + } m_lastStartTime = m_startTime; m_lastEndTime = m_endTime; @@ -357,7 +359,7 @@ void TimelineRenderer::manageHovered(int x, int y) // find if there's items in the time range int eventFrom = m_profilerDataModel->findFirstIndex(time); int eventTo = m_profilerDataModel->findLastIndex(time); - if (eventTo < eventFrom) { + if (eventTo < eventFrom || eventTo >= m_profilerDataModel->count()) { m_currentSelection.eventIndex = -1; return; }