diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2016-05-26 09:27:59 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2016-05-27 09:42:34 +0000 |
commit | 1b9b59a45f5f044e8a07c66c09965e550a8e8cee (patch) | |
tree | afc5459c1a2eeb8a4216d79931585de2ddf82030 /src/plugins/qmlprofiler/memoryusagemodel.cpp | |
parent | 1b650190d84d16184aaa71cd926bcda217c4c2c1 (diff) |
QmlProfiler: Use origin type's ID for memory allocations
We want the editor to jump to the right source location when selecting
different events from the timeline. If all memory events have the same
ID this doesn't work. Now they of course have the IDs of the origin
events, but that's not a problem because when you select first the
memory event and then its origin, the editor position does in fact not
have to change.
As an added benefit, the typeId cannot be -1 anymore now.
Change-Id: I95520eeb3e6902e046f3f552c74dba776e7c8b62
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/qmlprofiler/memoryusagemodel.cpp')
-rw-r--r-- | src/plugins/qmlprofiler/memoryusagemodel.cpp | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/src/plugins/qmlprofiler/memoryusagemodel.cpp b/src/plugins/qmlprofiler/memoryusagemodel.cpp index 88bfbcb6ceb..02b630eb7aa 100644 --- a/src/plugins/qmlprofiler/memoryusagemodel.cpp +++ b/src/plugins/qmlprofiler/memoryusagemodel.cpp @@ -77,15 +77,12 @@ QVariantMap MemoryUsageModel::location(int index) const QVariantMap result; - int originType = m_data[index].originTypeIndex; - if (originType > -1) { - const QmlEventLocation &location = - modelManager()->qmlModel()->eventTypes().at(originType).location; - - result.insert(file, location.filename); - result.insert(line, location.line); - result.insert(column, location.column); - } + const QmlEventLocation &location = + modelManager()->qmlModel()->eventTypes().at(m_data[index].typeId).location; + + result.insert(file, location.filename); + result.insert(line, location.line); + result.insert(column, location.column); return result; } @@ -128,10 +125,8 @@ QVariantMap MemoryUsageModel::details(int index) const } result.insert(tr("Type"), QVariant(memoryTypeName(selectionId(index)))); - if (ev->originTypeIndex != -1) { - result.insert(tr("Location"), - modelManager()->qmlModel()->eventTypes().at(ev->originTypeIndex).displayName); - } + result.insert(tr("Location"), + modelManager()->qmlModel()->eventTypes().at(ev->typeId).displayName); return result; } @@ -155,13 +150,15 @@ void MemoryUsageModel::loadEvent(const QmlEvent &event, const QmlEventType &type if (type.detailType == SmallItem || type.detailType == LargeItem) { if (!m_rangeStack.empty() && m_currentUsageIndex > -1 && type.detailType == selectionId(m_currentUsageIndex) && - m_data[m_currentUsageIndex].originTypeIndex == m_rangeStack.top().originTypeIndex && + m_data[m_currentUsageIndex].typeId == m_rangeStack.top().originTypeIndex && m_rangeStack.top().startTime < startTime(m_currentUsageIndex)) { m_data[m_currentUsageIndex].update(event.number<qint64>(0)); m_currentUsage = m_data[m_currentUsageIndex].size; } else { - MemoryAllocationItem allocation(event.typeIndex(), m_currentUsage, - m_rangeStack.empty() ? -1 : m_rangeStack.top().originTypeIndex); + MemoryAllocationItem allocation( + m_rangeStack.empty() ? event.typeIndex() : + m_rangeStack.top().originTypeIndex, + m_currentUsage); allocation.update(event.number<qint64>(0)); m_currentUsage = allocation.size; @@ -177,14 +174,16 @@ void MemoryUsageModel::loadEvent(const QmlEvent &event, const QmlEventType &type if (type.detailType == HeapPage || type.detailType == LargeItem) { if (!m_rangeStack.empty() && m_currentJSHeapIndex > -1 && type.detailType == selectionId(m_currentJSHeapIndex) && - m_data[m_currentJSHeapIndex].originTypeIndex == + m_data[m_currentJSHeapIndex].typeId == m_rangeStack.top().originTypeIndex && m_rangeStack.top().startTime < startTime(m_currentJSHeapIndex)) { m_data[m_currentJSHeapIndex].update(event.number<qint64>(0)); m_currentSize = m_data[m_currentJSHeapIndex].size; } else { - MemoryAllocationItem allocation(event.typeIndex(), m_currentSize, - m_rangeStack.empty() ? -1 : m_rangeStack.top().originTypeIndex); + MemoryAllocationItem allocation( + m_rangeStack.empty() ? event.typeIndex() : + m_rangeStack.top().originTypeIndex, + m_currentSize); allocation.update(event.number<qint64>(0)); m_currentSize = allocation.size; @@ -237,10 +236,9 @@ QString MemoryUsageModel::memoryTypeName(int type) } } -MemoryUsageModel::MemoryAllocationItem::MemoryAllocationItem(int type, qint64 baseAmount, - int originTypeIndex) : - typeId(type), size(baseAmount), allocated(0), deallocated(0), allocations(0), deallocations(0), - originTypeIndex(originTypeIndex) +MemoryUsageModel::MemoryAllocationItem::MemoryAllocationItem(int typeId, qint64 baseAmount) : + size(baseAmount), allocated(0), deallocated(0), allocations(0), deallocations(0), + typeId(typeId) { } |