From ef51b12f993b88c1ba57f7921e74c36c8a699b3e Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 8 Jul 2014 12:33:46 +0200 Subject: [PATCH 1/2] Replace lastTimeMark with traceEndTime for end time of memory profiler lastTimeMark is just the end of the last recorded event. The memory will still be allocated after that. Change-Id: Ica12993d7b1572c145bba6373461240a5e846fa9 Reviewed-by: Kai Koehne --- plugins/qmlprofilerextension/memoryusagemodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/qmlprofilerextension/memoryusagemodel.cpp b/plugins/qmlprofilerextension/memoryusagemodel.cpp index 8cf9a421584..8bd6ff27419 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.cpp +++ b/plugins/qmlprofilerextension/memoryusagemodel.cpp @@ -269,10 +269,10 @@ void MemoryUsageModel::loadData() } if (currentJSHeapIndex != -1) - d->insertEnd(currentJSHeapIndex, simpleModel->lastTimeMark() - + d->insertEnd(currentJSHeapIndex, traceEndTime() - d->range(currentJSHeapIndex).start - 1); if (currentUsageIndex != -1) - d->insertEnd(currentUsageIndex, simpleModel->lastTimeMark() - + d->insertEnd(currentUsageIndex, traceEndTime() - d->range(currentUsageIndex).start - 1); From 114c1dbc885abf7dd207d3f77ec3b146e7f3fe28 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 8 Jul 2014 17:32:34 +0200 Subject: [PATCH 2/2] Fix PixmapCacheModel to not get confused on plain LoadingFinished The indices SortedTimelineModel returns are only valid until you insert something at a different place than the end. If you do that, all later events are shifted by one. We can "fix" that by also shifting the saved indices. Change-Id: I63180dabea0c52db55e799b023b3f2bf84f9e59a Reviewed-by: Kai Koehne --- plugins/qmlprofilerextension/pixmapcachemodel.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index ea297b04bc1..f3b8a02761b 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextension/pixmapcachemodel.cpp @@ -456,6 +456,21 @@ void PixmapCacheModel::loadData() if (state.loadState == Initial) { newEvent.pixmapEventType = PixmapLoadingStarted; state.started = d->insert(traceStartTime(), startTime - traceStartTime(), newEvent); + + // All other indices are wrong now as we've prepended. Fix them ... + if (lastCacheSizeEvent >= state.started) + ++lastCacheSizeEvent; + + for (int pixmapIndex = 0; pixmapIndex < d->pixmaps.count(); ++pixmapIndex) { + Pixmap &brokenPixmap = d->pixmaps[pixmapIndex]; + for (int sizeIndex = 0; sizeIndex < brokenPixmap.sizes.count(); ++sizeIndex) { + PixmapState &brokenSize = brokenPixmap.sizes[sizeIndex]; + if ((pixmapIndex != newEvent.urlIndex || sizeIndex != newEvent.sizeIndex) && + brokenSize.started >= state.started) { + ++brokenSize.started; + } + } + } } d->insertEnd(state.started, startTime - d->range(state.started).start);