forked from qt-creator/qt-creator
QmlProfiler: Make sure we can handle inconsistent trace data
Apparently some versions of Qt can produce traces with unmatched start and end events. We should not crash on those. Change-Id: Idfb3273f02470156e9f1863c43477d0c3494e0d6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -72,13 +72,26 @@ void QmlProfilerRangeModel::loadEvent(const QmlEvent &event, const QmlEventType
|
||||
m_stack.append(index);
|
||||
m_data.insert(index, QmlRangeEventStartInstance());
|
||||
} else if (event.rangeStage() == RangeEnd) {
|
||||
int index = m_stack.pop();
|
||||
insertEnd(index, event.timestamp() - startTime(index));
|
||||
if (!m_stack.isEmpty()) {
|
||||
int index = m_stack.pop();
|
||||
insertEnd(index, event.timestamp() - startTime(index));
|
||||
} else {
|
||||
qWarning() << "Received inconsistent trace data from application.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerRangeModel::finalize()
|
||||
{
|
||||
if (!m_stack.isEmpty()) {
|
||||
qWarning() << "End times for some events are missing.";
|
||||
const qint64 endTime = modelManager()->traceTime()->endTime();
|
||||
do {
|
||||
int index = m_stack.pop();
|
||||
insertEnd(index, endTime - startTime(index));
|
||||
} while (!m_stack.isEmpty());
|
||||
}
|
||||
|
||||
// compute range nesting
|
||||
computeNesting();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user