From 8827bb38806e8266bec6e0ec23fedf8c1955c842 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Thu, 22 Mar 2018 21:06:13 +0100 Subject: [PATCH] libdbusmenu-qt: Remove nonexistant actions directly from the menu Summary: The getLayout response handler compares the new list of actions with the current actions in the menu and calls deleteLater on all actions which aren't part of the new list anymore. Then, it adds all actions from the new list which aren't part of the menu yet. As deleteLater only has an effect after the next event processing, the menu still contains them together with the added actions. This resulted in broken size calculations, as even for static menus the item count changed during aboutToShow. Note that this is not a proper solution for the resize issue, as the aboutToShow handler changes the menus content for a reason, the application is free to add/remove items at any point in time. Test Plan: The context menu for SNI items in the system tray shows at the correct position now. Only tested the wayland session. Reviewers: #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D11586 --- libdbusmenuqt/dbusmenuimporter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenuqt/dbusmenuimporter.cpp b/libdbusmenuqt/dbusmenuimporter.cpp index aab5a0436..e6892a86d 100644 --- a/libdbusmenuqt/dbusmenuimporter.cpp +++ b/libdbusmenuqt/dbusmenuimporter.cpp @@ -409,6 +409,7 @@ void DBusMenuImporter::slotGetLayoutFinished(QDBusPendingCallWatcher *watcher) for (QAction *action: menu->actions()) { int id = action->property(DBUSMENU_PROPERTY_ID).toInt(); if (! newDBusMenuItemIds.contains(id)) { + menu->removeAction(action); action->deleteLater(); d->m_actionForId.remove(id); }