File 0038-Fix-memory-leak-in-Appmenu-when-using-compact-menu.patch of Package plasma5-workspace
From e54a6122e38d22ee9b0b0ee8641122ef5b98fc4a Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Thu, 2 Feb 2017 00:12:26 +0000
Subject: [PATCH 38/44] Fix memory leak in Appmenu when using compact menu
Summary:
::createMenu sometimes creates a new menu, sometimes returns a pointer
to a menu from libdbusmenu that we shouldn't delete.
This patch makes any newly created menu delete itself on closure.
It then shuffles some code so that we only call createMenu after
doing checks.
Test Plan:
Ran in compact mode, clicked menu a few times
Ran in full mode, clicked a menu a few times
Reviewers: #plasma, broulik
Reviewed By: #plasma, broulik
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D4393
---
applets/appmenu/lib/appmenuapplet.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/applets/appmenu/lib/appmenuapplet.cpp b/applets/appmenu/lib/appmenuapplet.cpp
index 444893fc..cbdd2589 100644
--- a/applets/appmenu/lib/appmenuapplet.cpp
+++ b/applets/appmenu/lib/appmenuapplet.cpp
@@ -132,6 +132,7 @@ QMenu *AppMenuApplet::createMenu(int idx) const
action = (QAction *)data.value<void *>();
menu->addAction(action);
}
+ menu->setAttribute(Qt::WA_DeleteOnClose);
} else if (view() == FullView) {
const QModelIndex index = m_model->index(idx, 0);
const QVariant data = m_model->data(index, AppMenuModel::ActionRole);
@@ -151,12 +152,12 @@ void AppMenuApplet::onMenuAboutToHide()
void AppMenuApplet::trigger(QQuickItem *ctx, int idx)
{
- QMenu *actionMenu = createMenu(idx);
+ if (m_currentIndex == idx) {
+ return;
+ }
+ QMenu *actionMenu = createMenu(idx);
if (actionMenu) {
- if (m_currentIndex == idx) {
- return;
- }
if (ctx && ctx->window() && ctx->window()->mouseGrabberItem()) {
// FIXME event forge thing enters press and hold move mode :/
--
2.12.0