From 69999c70f14ef3fd03669ac034ef059960b008e8 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Wed, 11 Feb 2026 11:45:20 +0100 Subject: panels/panels: handle lifetime of internal actions Preventing a mem-leak on process leave. --- src/panels/places/placespanel.cpp | 12 ++++++------ src/panels/places/placespanel.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index 12d7619b8..ed2341872 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -42,18 +42,18 @@ PlacesPanel::PlacesPanel(QWidget *parent) slotTearDownRequested(index); }); - m_openInSplitView = new QAction(QIcon::fromTheme(QStringLiteral("view-split-left-right")), i18nc("@action:inmenu", "Open in Split View")); + m_openInSplitView = std::make_unique(QIcon::fromTheme(QStringLiteral("view-split-left-right")), i18nc("@action:inmenu", "Open in Split View")); m_openInSplitView->setPriority(QAction::HighPriority); - connect(m_openInSplitView, &QAction::triggered, this, [this]() { + connect(m_openInSplitView.get(), &QAction::triggered, this, [this]() { const QUrl url = currentIndex().data(KFilePlacesModel::UrlRole).toUrl(); Q_EMIT openInSplitViewRequested(url); }); - addAction(m_openInSplitView); + addAction(m_openInSplitView.get()); - m_configureTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("configure")), i18nc("@action:inmenu", "Configure Trash…")); + m_configureTrashAction = std::make_unique(QIcon::fromTheme(QStringLiteral("configure")), i18nc("@action:inmenu", "Configure Trash…")); m_configureTrashAction->setPriority(QAction::HighPriority); - connect(m_configureTrashAction, &QAction::triggered, this, &PlacesPanel::slotConfigureTrash); - addAction(m_configureTrashAction); + connect(m_configureTrashAction.get(), &QAction::triggered, this, &PlacesPanel::slotConfigureTrash); + addAction(m_configureTrashAction.get()); connect(this, &PlacesPanel::contextMenuAboutToShow, this, &PlacesPanel::slotContextMenuAboutToShow); diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index dd5cb6d9e..3bacfcb94 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -73,8 +73,8 @@ private: QPersistentModelIndex m_indexToTearDown; - QAction *m_configureTrashAction; - QAction *m_openInSplitView; + std::unique_ptr m_configureTrashAction; + std::unique_ptr m_openInSplitView; QAction *m_lockPanelsAction; }; -- cgit v1.3