From 2db8a17117bfb3a80c4e509f4059c8a98947b70b Mon Sep 17 00:00:00 2001 From: Lieven Hey Date: Tue, 10 Dec 2024 13:23:35 +0100 Subject: [PATCH] feat: remove memory leak when calling QLayout::replaceWidget --- src/callgraphwidget.cpp | 3 ++- src/frequencypage.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/callgraphwidget.cpp b/src/callgraphwidget.cpp index abfa80f2..de638fbf 100644 --- a/src/callgraphwidget.cpp +++ b/src/callgraphwidget.cpp @@ -42,7 +42,8 @@ CallgraphWidget::CallgraphWidget(Data::CallerCalleeResults results, KParts::Read generateCallgraph(m_currentSymbol); }); - layout()->replaceWidget(ui->graphPlaceholder, view->widget()); + auto oldWidget = layout()->replaceWidget(ui->graphPlaceholder, view->widget()); + delete oldWidget; updateColors(); m_interface->setLayoutMethod(KGraphViewer::KGraphViewerInterface::LayoutMethod::InternalLibrary); diff --git a/src/frequencypage.cpp b/src/frequencypage.cpp index e150c7e8..d0482946 100644 --- a/src/frequencypage.cpp +++ b/src/frequencypage.cpp @@ -51,7 +51,8 @@ FrequencyPage::FrequencyPage(PerfParser* parser, QWidget* parent) m_page->setupUi(this); - m_page->layout->replaceWidget(m_page->plotWidget, m_plot); + auto oldWidget = m_page->layout->replaceWidget(m_page->plotWidget, m_plot); + delete oldWidget; auto plotData = QSharedPointer::create();