Commit 3053e572 authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlProfiler: fix crash when no qml events available



Change-Id: I821ddfca6053eb0af819ba9e21b12d55856a0a3a
Reviewed-by: default avatarAurindam Jana <aurindam.jana@nokia.com>
parent db9cfc06
......@@ -344,27 +344,29 @@ void QmlProfilerEventList::addV8Event(int depth, const QString &function, const
void QmlProfilerEventList::QmlProfilerEventListPrivate::collectV8Statistics()
{
double totalTimes = 0;
double selfTimes = 0;
foreach (QV8EventData *v8event, m_v8EventList) {
totalTimes += v8event->totalTime;
selfTimes += v8event->selfTime;
}
if (!m_v8EventList.isEmpty()) {
double totalTimes = 0;
double selfTimes = 0;
foreach (QV8EventData *v8event, m_v8EventList) {
totalTimes += v8event->totalTime;
selfTimes += v8event->selfTime;
}
// prevent divisions by 0
if (totalTimes == 0)
totalTimes = 1;
if (selfTimes == 0)
selfTimes = 1;
// prevent divisions by 0
if (totalTimes == 0)
totalTimes = 1;
if (selfTimes == 0)
selfTimes = 1;
foreach (QV8EventData *v8event, m_v8EventList) {
v8event->totalPercent = v8event->totalTime * 100.0 / totalTimes;
v8event->selfPercent = v8event->selfTime * 100.0 / selfTimes;
}
foreach (QV8EventData *v8event, m_v8EventList) {
v8event->totalPercent = v8event->totalTime * 100.0 / totalTimes;
v8event->selfPercent = v8event->selfTime * 100.0 / selfTimes;
}
int index = 0;
foreach (QV8EventData *v8event, m_v8EventList)
v8event->eventId = index++;
int index = 0;
foreach (QV8EventData *v8event, m_v8EventList)
v8event->eventId = index++;
}
}
void QmlProfilerEventList::setTraceEndTime( qint64 time )
......@@ -637,12 +639,15 @@ void QmlProfilerEventList::computeNestingDepth()
void QmlProfilerEventList::postProcess()
{
sortStartTimes();
sortEndTimes();
computeLevels();
linkEndsToStarts();
prepareForDisplay();
compileStatistics(traceStartTime(), traceEndTime());
if (count() != 0) {
sortStartTimes();
sortEndTimes();
computeLevels();
linkEndsToStarts();
prepareForDisplay();
compileStatistics(traceStartTime(), traceEndTime());
}
// data is ready even when there's no data
emit dataReady();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment