forked from qt-creator/qt-creator
QmlProfiler: Properly handle very large ranges when restricting
Previously, a range starting before the restriction and ending after it would not be recognized as belonging to the restricted range. Change-Id: I4d387f8964362635cc2bc89a6a082a4a5bfeddcb Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -205,6 +205,7 @@ void QmlProfilerDataModel::replayEvents(qint64 rangeStart, qint64 rangeEnd,
|
||||
QFile file(d->file.fileName());
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QDataStream stream(&file);
|
||||
bool crossedRangeStart = false;
|
||||
while (!stream.atEnd()) {
|
||||
stream >> event;
|
||||
if (stream.status() == QDataStream::ReadPastEnd)
|
||||
@@ -212,7 +213,8 @@ void QmlProfilerDataModel::replayEvents(qint64 rangeStart, qint64 rangeEnd,
|
||||
|
||||
const QmlEventType &type = d->eventTypes[event.typeIndex()];
|
||||
if (rangeStart != -1 && rangeEnd != -1) {
|
||||
if (event.timestamp() < rangeStart) {
|
||||
// Double-check if rangeStart has been crossed. Some versions of Qt send dirty data.
|
||||
if (event.timestamp() < rangeStart && !crossedRangeStart) {
|
||||
if (type.rangeType() != MaximumRangeType) {
|
||||
if (event.rangeStage() == RangeStart)
|
||||
stack.push(event);
|
||||
@@ -224,7 +226,16 @@ void QmlProfilerDataModel::replayEvents(qint64 rangeStart, qint64 rangeEnd,
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (event.timestamp() > rangeEnd) {
|
||||
} else {
|
||||
if (!crossedRangeStart) {
|
||||
foreach (QmlEvent stashed, stack) {
|
||||
stashed.setTimestamp(rangeStart);
|
||||
loader(stashed, d->eventTypes[stashed.typeIndex()]);
|
||||
}
|
||||
stack.clear();
|
||||
crossedRangeStart = true;
|
||||
}
|
||||
if (event.timestamp() > rangeEnd) {
|
||||
if (type.rangeType() != MaximumRangeType) {
|
||||
if (event.rangeStage() == RangeEnd) {
|
||||
if (stack.isEmpty()) {
|
||||
@@ -243,12 +254,7 @@ void QmlProfilerDataModel::replayEvents(qint64 rangeStart, qint64 rangeEnd,
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (!stack.isEmpty()) {
|
||||
foreach (QmlEvent stashed, stack) {
|
||||
stashed.setTimestamp(rangeStart);
|
||||
loader(stashed, d->eventTypes[stashed.typeIndex()]);
|
||||
}
|
||||
stack.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user