aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/perfprofiler
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-01-23 11:17:39 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2020-01-23 12:12:51 +0000
commit1a3965f0254eba7835404fce7467d2bfc135c31f (patch)
tree37313d79c477da49ee67fc1ded5cd0ca4683695a /src/plugins/perfprofiler
parent1ec201d4636c0b2a8cdcda8731e628235997bcc0 (diff)
PerfProfiler: Fix memory leak
If the tool view is never shown, the respective widgets have no owner and need to be deleted manually. Change-Id: I6db7113d864607ae233f792363f13cfe841ccd10 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/perfprofiler')
-rw-r--r--src/plugins/perfprofiler/perfprofilertool.cpp10
-rw-r--r--src/plugins/perfprofiler/perfprofilertool.h3
2 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/perfprofiler/perfprofilertool.cpp b/src/plugins/perfprofiler/perfprofilertool.cpp
index ad144c6670..5dc99eecea 100644
--- a/src/plugins/perfprofiler/perfprofilertool.cpp
+++ b/src/plugins/perfprofiler/perfprofilertool.cpp
@@ -138,6 +138,7 @@ PerfProfilerTool::PerfProfilerTool()
m_tracePointsButton = new QToolButton;
m_tracePointsButton->setDefaultAction(tracePointsAction);
+ m_objectsToDelete << m_tracePointsButton;
auto action = new QAction(tr("Performance Analyzer"), this);
action->setToolTip(tr("Finds performance bottlenecks."));
@@ -150,6 +151,7 @@ PerfProfilerTool::PerfProfilerTool()
m_startAction = Debugger::createStartAction();
m_stopAction = Debugger::createStopAction();
+ m_objectsToDelete << m_startAction << m_stopAction;
QObject::connect(m_startAction, &QAction::triggered, action, &QAction::triggered);
QObject::connect(m_startAction, &QAction::changed, action, [action, tracePointsAction, this] {
@@ -169,13 +171,21 @@ PerfProfilerTool::PerfProfilerTool()
m_recordedLabel->setProperty("panelwidget", true);
m_delayLabel = new QLabel;
m_delayLabel->setProperty("panelwidget", true);
+ m_objectsToDelete << m_recordButton << m_clearButton << m_filterButton << m_aggregateButton
+ << m_recordedLabel << m_delayLabel;
m_perspective.setAboutToActivateCallback([this]() { createViews(); });
updateRunActions();
}
+PerfProfilerTool::~PerfProfilerTool()
+{
+ qDeleteAll(m_objectsToDelete);
+}
+
void PerfProfilerTool::createViews()
{
+ m_objectsToDelete.clear();
m_traceView = new PerfProfilerTraceView(nullptr, this);
m_traceView->setWindowTitle(tr("Timeline"));
connect(m_traceView, &PerfProfilerTraceView::gotoSourceLocation,
diff --git a/src/plugins/perfprofiler/perfprofilertool.h b/src/plugins/perfprofiler/perfprofilertool.h
index cd8c01764c..205b47b8ca 100644
--- a/src/plugins/perfprofiler/perfprofilertool.h
+++ b/src/plugins/perfprofiler/perfprofilertool.h
@@ -49,6 +49,8 @@ class PerfProfilerTool : public QObject
Q_OBJECT
public:
PerfProfilerTool();
+ ~PerfProfilerTool();
+
static PerfProfilerTool *instance();
PerfProfilerTraceManager *traceManager() const;
@@ -115,6 +117,7 @@ private:
QMenu *m_filterMenu = nullptr;
QToolButton *m_aggregateButton = nullptr;
QToolButton *m_tracePointsButton = nullptr;
+ QList<QObject *> m_objectsToDelete;
PerfProfilerTraceView *m_traceView = nullptr;
PerfProfilerStatisticsView *m_statisticsView = nullptr;