QmlProfiler: Avoid structs with default values

gcc 4.9 and msvc 2015 choke when creating those from initializer lists.

Change-Id: I85936fe33418d5d9ffeb3c910392ad43fbb9a9bb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Stenger
2018-04-12 12:08:48 +02:00
committed by Ulf Hermann
parent 1155601da5
commit c637c66ebb
2 changed files with 11 additions and 12 deletions

View File

@@ -370,7 +370,7 @@ void QmlProfilerStatisticsRelativesModel::loadEvent(RangeType type, const QmlEve
switch (event.rangeStage()) {
case RangeStart:
stack.push({event.timestamp(), event.typeIndex()});
stack.push(Frame(event.timestamp(), event.typeIndex()));
break;
case RangeEnd: {
int callerTypeIndex = stack.count() > 1 ? stack[stack.count() - 2].typeId : -1;
@@ -386,12 +386,8 @@ void QmlProfilerStatisticsRelativesModel::loadEvent(RangeType type, const QmlEve
it->duration += event.timestamp() - stack.top().startTime;
it->isRecursive = isRecursive || it->isRecursive;
} else {
QmlStatisticsRelativesData relative = {
event.timestamp() - stack.top().startTime,
1,
isRecursive
};
relativesMap.insert(relativeTypeIndex, relative);
relativesMap.insert(relativeTypeIndex, QmlStatisticsRelativesData(
event.timestamp() - stack.top().startTime, 1, isRecursive));
}
stack.pop();
break;

View File

@@ -113,9 +113,11 @@ class QmlProfilerStatisticsRelativesModel : public QObject
public:
struct QmlStatisticsRelativesData {
qint64 duration = 0;
qint64 calls = 0;
bool isRecursive = false;
QmlStatisticsRelativesData(qint64 duration = 0, qint64 calls = 0, bool isRecursive = false)
: duration(duration), calls(calls), isRecursive(isRecursive) {}
qint64 duration;
qint64 calls;
bool isRecursive;
};
typedef QHash <int, QmlStatisticsRelativesData> QmlStatisticsRelativesMap;
@@ -141,8 +143,9 @@ protected:
QPointer<QmlProfilerModelManager> m_modelManager;
struct Frame {
qint64 startTime = 0;
int typeId = -1;
Frame(qint64 startTime = 0, int typeId = -1) : startTime(startTime), typeId(typeId) {}
qint64 startTime;
int typeId;
};
QStack<Frame> m_callStack;
QStack<Frame> m_compileStack;