From e3ae628584f2434b6cc9210726deafd55769c260 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 8 Sep 2017 10:00:12 +0200 Subject: [PATCH] QmlProfiler: Don't crash on inconsistent profiling data The trace may contain RangeData and RangeLocation entries that aren't aligned with any RangeStart. As the trace is generated by an external process we need to handle that. Change-Id: I39a524127c9c9059e5c5521797e5effd385ce12b Reviewed-by: Milian Wolff --- src/plugins/qmlprofiler/qmlprofilertraceclient.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp b/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp index a48123a9a40..0ed31a2036b 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp @@ -138,7 +138,8 @@ void QmlProfilerTraceClientPrivate::processCurrentEvent() break; case RangeEnd: { int typeIndex = resolveStackTop(); - QTC_ASSERT(typeIndex != -1, break); + if (typeIndex == -1) + break; currentEvent.event.setTypeIndex(typeIndex); while (!pendingMessages.isEmpty()) modelManager->addEvent(pendingMessages.dequeue()); @@ -147,10 +148,12 @@ void QmlProfilerTraceClientPrivate::processCurrentEvent() break; } case RangeData: - rangesInProgress.top().type.setData(currentEvent.type.data()); + if (!rangesInProgress.isEmpty()) + rangesInProgress.top().type.setData(currentEvent.type.data()); break; case RangeLocation: - rangesInProgress.top().type.setLocation(currentEvent.type.location()); + if (!rangesInProgress.isEmpty()) + rangesInProgress.top().type.setLocation(currentEvent.type.location()); break; default: { int typeIndex = resolveType(currentEvent);