Reuse QAction and QMenu items on updates

Authored by davidedmundson on Jan 11 2017, 1:52 PM.

Description

Reuse QAction and QMenu items on updates

Summary:
When updating a menu we would always delete all the actions and recreate
them.

This caused a problem that we would also be deleting submenus and
recreating them, meaning when we update the applet's submenu before
showing it, our submenu will always be destroyed.

This patch uses the DBusMenuItem IDs to re-use existing QAction / QMenu
objects and only create new instances when needed. It should also be (in
theory) faster as there's a lot less object creation every update.

Also replace QSignalMapper with a lambda and replace replace QMap<int,
QPointer<QAction*> with QMap<int, QAction*> and a lambda to do cleanup
on deletion.

Test Plan:
Tweked the applet to update before showing
Original QMenu object used before showing still has all the items

Reviewers: Plasma

Subscribers: broulik, markg, plasma-devel

Tags: Plasma

Differential Revision: https://phabricator.kde.org/D4057

Details

Committed
davidedmundsonJan 11 2017, 1:54 PM
Differential Revision
D4057: Reuse QAction and QMenu items on updates
Parents
R120:b9af99140365: [System Tray] Trigger context menu on press
Branches
Unknown
Tags
Unknown