From 213ed50634c02d8ec4aa91f0c307cfdd6f78170d Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Wed, 29 Jan 2020 19:50:33 +0100 Subject: Fix memory leak in KUrlNavigatorPlacesSelector::updateMenu Summary: This method gets called each time solid notices a change, which can in some setups be very frequent. It leaked memory as the submenus and their actions were not deallocated properly. Test Plan: Builds. User feedback: "so far so good, 160 MB Memory usage". It was ~7GiB before this patch. Reviewers: #frameworks, davidedmundson, meven Reviewed By: davidedmundson, meven Subscribers: anthonyfieroni, meven, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27002 --- src/filewidgets/kurlnavigatorplacesselector.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/filewidgets/kurlnavigatorplacesselector.cpp b/src/filewidgets/kurlnavigatorplacesselector.cpp index 7d33930..103a5fc 100644 --- a/src/filewidgets/kurlnavigatorplacesselector.cpp +++ b/src/filewidgets/kurlnavigatorplacesselector.cpp @@ -71,6 +71,11 @@ void KUrlNavigatorPlacesSelector::updateMenu() { m_placesMenu->clear(); + // Submenus have to be deleted explicitly (QTBUG-11070) + for(QObject *obj : QObjectList(m_placesMenu->children())) { + delete qobject_cast(obj); // Noop for nullptr + } + updateSelection(m_selectedUrl); QString previousGroup; -- cgit v1.1