From 80539089c9e7d3d42035def53c452f175be812ab Mon Sep 17 00:00:00 2001 From: Jonathan Marten Date: Wed, 8 Jun 2022 14:10:36 +0100 Subject: [PATCH] Klipper (classic widget): Fix a system tray menu memory leak Clipboard history item actions are added to the menu by KlipperPopup::rebuild() or PopupProxy::tryInsertItem(). The actions are removed from the menu again at the start of KlipperPopup::rebuild(), but were never deleted. --- klipper/klipperpopup.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/klipper/klipperpopup.cpp b/klipper/klipperpopup.cpp index eefaa70dbe..e68780102b 100644 --- a/klipper/klipperpopup.cpp +++ b/klipper/klipperpopup.cpp @@ -138,7 +138,13 @@ void KlipperPopup::rebuild(const QString &filter) } else { for (int i = 0; i < m_nHistoryItems; i++) { Q_ASSERT(TOP_HISTORY_ITEM_INDEX < actions().count()); - removeAction(actions().at(TOP_HISTORY_ITEM_INDEX)); + + // The old actions allocated by KlipperPopup::rebuild() + // and PopupProxy::tryInsertItem() are deleted here when + // the menu is rebuilt. + QAction *action = actions().at(TOP_HISTORY_ITEM_INDEX); + removeAction(action); + action->deleteLater(); } } -- GitLab