Skip to content

Commit

Permalink
feat: remove memory leak when calling QLayout::replaceWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
lievenhey committed Jan 14, 2025
1 parent 7b4802a commit 2db8a17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/callgraphwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/frequencypage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlotData>::create();

Expand Down

0 comments on commit 2db8a17

Please sign in to comment.