Commit 1b9b59a4 authored by Ulf Hermann's avatar Ulf Hermann

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: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Ulf Hermann's avatarUlf Hermann <ulf.hermann@qt.io>
parent 1b650190
......@@ -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)
{
}
......
......@@ -41,15 +41,14 @@ class MemoryUsageModel : public QmlProfilerTimelineModel
public:
struct MemoryAllocationItem {
int typeId;
qint64 size;
qint64 allocated;
qint64 deallocated;
int allocations;
int deallocations;
int originTypeIndex;
int typeId;
MemoryAllocationItem(int typeId = -1, qint64 baseAmount = 0, int originTypeIndex = -1);
MemoryAllocationItem(int typeId = -1, qint64 baseAmount = 0);
void update(qint64 amount);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment