forked from qt-creator/qt-creator
QmlProfiler: Clean up type selection in statistics model
The statistics have one extra valid event type: "Main Program". This should not be mapped to typeId -1, as -1 is the invalid typeId. Map it instead to std::numeric_limits<int>::max() and remove all the hacks around it. Additionally, optimize the selection algorithm for the statistics main view: We don't need to iterate all types to select one. We can rather use the fact that the row numbers in the source model match the type indices (except for the two special ones). Change-Id: I7c4dc4f84fd167f9a21c418466ad2bfce56e441f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -145,6 +145,9 @@ public:
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
static const int s_mainEntryTypeId = std::numeric_limits<int>::max();
|
||||
static const int s_invalidTypeId = -1;
|
||||
|
||||
private:
|
||||
void loadEvent(const QmlEvent &event, const QmlEventType &type);
|
||||
void finalize();
|
||||
@@ -178,7 +181,8 @@ class QmlProfilerStatisticsRelativesModel : public QAbstractTableModel
|
||||
public:
|
||||
|
||||
struct QmlStatisticsRelativesData {
|
||||
QmlStatisticsRelativesData(qint64 duration = 0, qint64 calls = 0, int typeIndex = -1,
|
||||
QmlStatisticsRelativesData(qint64 duration = 0, qint64 calls = 0,
|
||||
int typeIndex = QmlProfilerStatisticsModel::s_invalidTypeId,
|
||||
bool isRecursive = false)
|
||||
: duration(duration), calls(calls), typeIndex(typeIndex), isRecursive(isRecursive) {}
|
||||
qint64 duration;
|
||||
@@ -207,10 +211,11 @@ private:
|
||||
QHash<int, QVector<QmlStatisticsRelativesData>> m_data;
|
||||
QPointer<QmlProfilerModelManager> m_modelManager;
|
||||
|
||||
int m_relativeTypeIndex = std::numeric_limits<int>::max();
|
||||
int m_relativeTypeIndex = QmlProfilerStatisticsModel::s_invalidTypeId;
|
||||
|
||||
struct Frame {
|
||||
Frame(qint64 startTime = 0, int typeId = -1) : startTime(startTime), typeId(typeId) {}
|
||||
Frame(qint64 startTime = 0, int typeId = QmlProfilerStatisticsModel::s_invalidTypeId)
|
||||
: startTime(startTime), typeId(typeId) {}
|
||||
qint64 startTime;
|
||||
int typeId;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user