forked from qt-creator/qt-creator
QmlProfiler: Fix crash when loading traces
Don't keep a pointer to elements in QVector (which might get relocated at any time). Instead, store the index. Change-Id: If24a408b9f47f0f3a83909ff119867311d87d869 Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
This commit is contained in:
committed by
Kai Koehne
parent
1f4d831f8c
commit
5506d0329f
@@ -203,7 +203,7 @@ public:
|
|||||||
qint64 traceStartTime;
|
qint64 traceStartTime;
|
||||||
qint64 qmlMeasuredTime;
|
qint64 qmlMeasuredTime;
|
||||||
|
|
||||||
QmlRangeEventStartInstance *lastFrameEvent;
|
int lastFrameEventIndex;
|
||||||
qint64 maxAnimationCount;
|
qint64 maxAnimationCount;
|
||||||
qint64 minAnimationCount;
|
qint64 minAnimationCount;
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ QmlProfilerDataModel::QmlProfilerDataModel(QObject *parent) :
|
|||||||
d->traceStartTime = -1;
|
d->traceStartTime = -1;
|
||||||
d->qmlMeasuredTime = 0;
|
d->qmlMeasuredTime = 0;
|
||||||
d->clearQmlRootEvent();
|
d->clearQmlRootEvent();
|
||||||
d->lastFrameEvent = 0;
|
d->lastFrameEventIndex = -1;
|
||||||
d->maxAnimationCount = 0;
|
d->maxAnimationCount = 0;
|
||||||
d->minAnimationCount = 0;
|
d->minAnimationCount = 0;
|
||||||
d->v8DataModel = new QV8ProfilerDataModel(this, this);
|
d->v8DataModel = new QV8ProfilerDataModel(this, this);
|
||||||
@@ -283,7 +283,7 @@ void QmlProfilerDataModel::clear()
|
|||||||
d->traceStartTime = -1;
|
d->traceStartTime = -1;
|
||||||
d->qmlMeasuredTime = 0;
|
d->qmlMeasuredTime = 0;
|
||||||
|
|
||||||
d->lastFrameEvent = 0;
|
d->lastFrameEventIndex = -1;
|
||||||
d->maxAnimationCount = 0;
|
d->maxAnimationCount = 0;
|
||||||
d->minAnimationCount = 0;
|
d->minAnimationCount = 0;
|
||||||
|
|
||||||
@@ -401,11 +401,14 @@ void QmlProfilerDataModel::addFrameEvent(qint64 time, int framerate, int animati
|
|||||||
|
|
||||||
qint64 length = 1e9/framerate;
|
qint64 length = 1e9/framerate;
|
||||||
// avoid overlap
|
// avoid overlap
|
||||||
if (d->lastFrameEvent &&
|
QmlRangeEventStartInstance *lastFrameEvent = 0;
|
||||||
d->lastFrameEvent->startTime + d->lastFrameEvent->duration >= time) {
|
if (d->lastFrameEventIndex > -1) {
|
||||||
d->lastFrameEvent->duration = time - 1 - d->lastFrameEvent->startTime;
|
lastFrameEvent = &d->startInstanceList[d->lastFrameEventIndex];
|
||||||
d->endInstanceList[d->lastFrameEvent->endTimeIndex].endTime =
|
if (lastFrameEvent->startTime + lastFrameEvent->duration >= time) {
|
||||||
d->lastFrameEvent->startTime + d->lastFrameEvent->duration;
|
lastFrameEvent->duration = time - 1 - lastFrameEvent->startTime;
|
||||||
|
d->endInstanceList[lastFrameEvent->endTimeIndex].endTime =
|
||||||
|
lastFrameEvent->startTime + lastFrameEvent->duration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlRangeEventEndInstance endTimeData;
|
QmlRangeEventEndInstance endTimeData;
|
||||||
@@ -425,7 +428,7 @@ void QmlProfilerDataModel::addFrameEvent(qint64 time, int framerate, int animati
|
|||||||
d->endInstanceList << endTimeData;
|
d->endInstanceList << endTimeData;
|
||||||
d->startInstanceList << startTimeData;
|
d->startInstanceList << startTimeData;
|
||||||
|
|
||||||
d->lastFrameEvent = &d->startInstanceList.last();
|
d->lastFrameEventIndex = d->startInstanceList.count() - 1;
|
||||||
|
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
}
|
}
|
||||||
@@ -941,13 +944,13 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::findAnimationLimits()
|
|||||||
{
|
{
|
||||||
maxAnimationCount = 0;
|
maxAnimationCount = 0;
|
||||||
minAnimationCount = 0;
|
minAnimationCount = 0;
|
||||||
lastFrameEvent = 0;
|
lastFrameEventIndex = -1;
|
||||||
|
|
||||||
for (int i = 0; i < startInstanceList.count(); i++) {
|
for (int i = 0; i < startInstanceList.count(); i++) {
|
||||||
if (startInstanceList[i].statsInfo->eventType == QmlDebug::Painting &&
|
if (startInstanceList[i].statsInfo->eventType == QmlDebug::Painting &&
|
||||||
startInstanceList[i].animationCount >= 0) {
|
startInstanceList[i].animationCount >= 0) {
|
||||||
int animationcount = startInstanceList[i].animationCount;
|
int animationcount = startInstanceList[i].animationCount;
|
||||||
if (lastFrameEvent) {
|
if (lastFrameEventIndex > -1) {
|
||||||
if (animationcount > maxAnimationCount)
|
if (animationcount > maxAnimationCount)
|
||||||
maxAnimationCount = animationcount;
|
maxAnimationCount = animationcount;
|
||||||
if (animationcount < minAnimationCount)
|
if (animationcount < minAnimationCount)
|
||||||
@@ -956,7 +959,7 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::findAnimationLimits()
|
|||||||
maxAnimationCount = animationcount;
|
maxAnimationCount = animationcount;
|
||||||
minAnimationCount = animationcount;
|
minAnimationCount = animationcount;
|
||||||
}
|
}
|
||||||
lastFrameEvent = &startInstanceList[i];
|
lastFrameEventIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user