aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-01-03 13:40:48 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-01-03 13:51:47 +0000
commit4a5bd323a9bc9c2de44e92f8414ed283feb314b1 (patch)
treebb3968d1868ae1f2b0557250894d3e8ac48c4d3a /src
parentffe120a43ff93e9ba0b37e987496c886c3274ad9 (diff)
QmlProfiler: Retain event types between sessions on same connection
The server won't re-send the event types. We need to keep them until the connection goes away. Otherwise we get invalid event types and soft asserts when trying to look up event types for new events. Also, when clearing the event types, also clear the server type IDs. Not clearing those constitutes a memory leak. Change-Id: I564b0c4cf0ed754549d2b8ede63c97fa01affcec Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp6
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerclientmanager.h1
-rw-r--r--src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp19
-rw-r--r--src/plugins/qmlprofiler/qmlprofilermodelmanager.h2
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.cpp11
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.h1
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertraceclient.cpp10
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertraceclient.h1
8 files changed, 43 insertions, 8 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
index 7f0677af7bc..248ebe485b8 100644
--- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
@@ -88,6 +88,12 @@ void QmlProfilerClientManager::clearConnection()
stopConnectionTimer();
}
+void QmlProfilerClientManager::clearEvents()
+{
+ if (m_qmlclientplugin)
+ m_qmlclientplugin->clearEvents();
+}
+
void QmlProfilerClientManager::clearBufferedData()
{
if (m_qmlclientplugin)
diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h
index c64429abc70..15af88bbc2d 100644
--- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h
+++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h
@@ -50,6 +50,7 @@ public:
void connectToServer(const QUrl &server);
void clearConnection();
+ void clearEvents();
void clearBufferedData();
bool isConnected() const;
diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
index 7c85817841e..687ad50db56 100644
--- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
@@ -691,9 +691,8 @@ QmlProfilerModelManager::State QmlProfilerModelManager::state() const
return d->state;
}
-void QmlProfilerModelManager::clear()
+void QmlProfilerModelManager::doClearEvents()
{
- setState(ClearingData);
d->numLoadedEvents = 0;
d->numFinishedFinalizers = 0;
d->file.remove();
@@ -702,13 +701,25 @@ void QmlProfilerModelManager::clear()
d->eventStream.setDevice(&d->file);
else
emit error(tr("Cannot open temporary trace file to store events."));
- d->eventTypes.clear();
- d->detailsRewriter->clear();
d->traceTime->clear();
d->notesModel->clear();
setVisibleFeatures(0);
setRecordedFeatures(0);
+}
+void QmlProfilerModelManager::clearEvents()
+{
+ setState(ClearingData);
+ doClearEvents();
+ setState(Empty);
+}
+
+void QmlProfilerModelManager::clear()
+{
+ setState(ClearingData);
+ doClearEvents();
+ d->eventTypes.clear();
+ d->detailsRewriter->clear();
setState(Empty);
}
diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h
index f09537667e5..b0ecd6ddcb4 100644
--- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h
+++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h
@@ -134,6 +134,7 @@ public:
static const char *featureName(ProfileFeature feature);
+ void clearEvents();
void clear();
void restrictToRange(qint64 startTime, qint64 endTime);
bool isRestrictedToRange() const;
@@ -156,6 +157,7 @@ signals:
private:
void setState(State state);
void detailsChanged(int typeId, const QString &newString);
+ void doClearEvents();
class QmlProfilerModelManagerPrivate;
QmlProfilerModelManagerPrivate *d;
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp
index 9966b2132d8..3b4f48aaa36 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp
@@ -405,7 +405,7 @@ void QmlProfilerTool::recordingButtonChanged(bool recording)
if (checkForUnsavedNotes()) {
if (!d->m_profilerModelManager->aggregateTraces() ||
d->m_profilerModelManager->state() == QmlProfilerModelManager::Done)
- clearData(); // clear before the recording starts, unless we aggregate recordings
+ clearEvents(); // clear before the recording starts, unless we aggregate recordings
if (d->m_profilerState->clientRecording())
d->m_profilerState->setClientRecording(false);
d->m_profilerState->setClientRecording(true);
@@ -469,6 +469,13 @@ void QmlProfilerTool::showTimeLineSearch()
Core::Find::openFindToolBar(Core::Find::FindForwardDirection);
}
+void QmlProfilerTool::clearEvents()
+{
+ d->m_profilerModelManager->clearEvents();
+ d->m_profilerConnections->clearEvents();
+ setRecordedFeatures(0);
+}
+
void QmlProfilerTool::clearData()
{
d->m_profilerModelManager->clear();
@@ -859,7 +866,7 @@ void QmlProfilerTool::serverRecordingChanged()
d->m_recordingElapsedTime.start();
if (!d->m_profilerModelManager->aggregateTraces() ||
d->m_profilerModelManager->state() == QmlProfilerModelManager::Done)
- clearData();
+ clearEvents();
d->m_profilerModelManager->startAcquiring();
} else {
d->m_recordingTimer.stop();
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h
index 4b784dfe8e1..334e51aeed2 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.h
+++ b/src/plugins/qmlprofiler/qmlprofilertool.h
@@ -74,6 +74,7 @@ public:
void gotoSourceLocation(const QString &fileUrl, int lineNumber, int columnNumber);
private:
+ void clearEvents();
void clearData();
void showErrorDialog(const QString &error);
void profilerDataModelStateChanged();
diff --git a/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp b/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp
index 6bf359c9242..93fea88900d 100644
--- a/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp
@@ -213,9 +213,8 @@ QmlProfilerTraceClient::~QmlProfilerTraceClient()
delete d;
}
-void QmlProfilerTraceClient::clearData()
+void QmlProfilerTraceClient::clearEvents()
{
- d->eventTypeIds.clear();
d->rangesInProgress.clear();
d->pendingDebugMessages.clear();
if (d->recordedFeatures != 0) {
@@ -225,6 +224,13 @@ void QmlProfilerTraceClient::clearData()
emit cleared();
}
+void QmlProfilerTraceClient::clearData()
+{
+ d->eventTypeIds.clear();
+ d->serverTypeIds.clear();
+ clearEvents();
+}
+
void QmlProfilerTraceClient::sendRecordingStatus(int engineId)
{
d->sendRecordingStatus(engineId);
diff --git a/src/plugins/qmlprofiler/qmlprofilertraceclient.h b/src/plugins/qmlprofiler/qmlprofilertraceclient.h
index b0f17c97893..6aa877d060a 100644
--- a/src/plugins/qmlprofiler/qmlprofilertraceclient.h
+++ b/src/plugins/qmlprofiler/qmlprofilertraceclient.h
@@ -55,6 +55,7 @@ public:
virtual void messageReceived(const QByteArray &) override;
virtual void stateChanged(State status) override;
+ void clearEvents();
void clearData();
void sendRecordingStatus(int engineId = -1);
void setRequestedFeatures(quint64 features);