aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-03-28 09:42:28 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-04-17 12:20:57 +0000
commitdcd8d37f351803fc0a1b9402b6503fd8dce93a09 (patch)
tree81bd147064da73d89c4190367e09228e89a22c7f /src/plugins/qmlprofiler/qmlprofilertracefile.cpp
parent7ca958fa85a9855ae658eaa3fa38e60b1279fb04 (diff)
QmlProfiler: Don't expose the vector of event types
We always want either the total number of event types or one specific type. There is no need to expose the fact that we keep them as a vector. Also, use int as the type of the "number" methods as that aligns better with Qt containers, and rename the methods. We don't need to state the fact that we've loaded the events and types at some point. Change-Id: Iaf680ec9fa10e1070ddee6bcc079800e401775f0 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilertracefile.cpp')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertracefile.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
index 972b8c2f126..ec1fe76e1d7 100644
--- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
@@ -227,7 +227,19 @@ void QmlProfilerFileReader::loadQzt(QIODevice *device)
stream >> data;
buffer.setData(qUncompress(data));
buffer.open(QIODevice::ReadOnly);
- bufferStream >> m_eventTypes;
+ quint32 numEventTypes;
+ bufferStream >> numEventTypes;
+ if (numEventTypes > std::numeric_limits<int>::max()) {
+ emit error(tr("Excessive number of event types: %1").arg(numEventTypes));
+ return;
+ }
+ QTC_ASSERT(m_eventTypes.isEmpty(), m_eventTypes.clear());
+ m_eventTypes.reserve(static_cast<int>(numEventTypes));
+ QmlEventType type;
+ for (int typeId = 0; typeId < static_cast<int>(numEventTypes); ++typeId) {
+ bufferStream >> type;
+ m_eventTypes.append(type);
+ }
buffer.close();
emit typesLoaded(m_eventTypes);
updateProgress(device);
@@ -676,11 +688,10 @@ void QmlProfilerFileWriter::saveQtd(QIODevice *device)
stream.writeStartElement(_("eventData"));
stream.writeAttribute(_("totalTime"), QString::number(m_measuredTime));
- const QVector<QmlEventType> &eventTypes = m_modelManager->eventTypes();
- for (int typeIndex = 0, end = eventTypes.length(); typeIndex < end && !isCanceled();
- ++typeIndex) {
+ for (int typeIndex = 0, end = m_modelManager->numEventTypes();
+ typeIndex < end && !isCanceled(); ++typeIndex) {
- const QmlEventType &type = eventTypes[typeIndex];
+ const QmlEventType &type = m_modelManager->eventType(typeIndex);
stream.writeStartElement(_("event"));
stream.writeAttribute(_("index"), QString::number(typeIndex));
@@ -856,7 +867,10 @@ void QmlProfilerFileWriter::saveQzt(QFile *file)
buffer.open(QIODevice::WriteOnly);
if (!isCanceled()) {
- bufferStream << m_modelManager->eventTypes();
+ const int numEventTypes = m_modelManager->numEventTypes();
+ bufferStream << static_cast<quint32>(numEventTypes);
+ for (int typeId = 0; typeId < numEventTypes; ++typeId)
+ bufferStream << m_modelManager->eventType(typeId);
stream << qCompress(buffer.data());
buffer.close();
buffer.buffer().clear();