Skip to content
Commit 1754c135 authored by David Edmundson's avatar David Edmundson
Browse files

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
parent b9af9914
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment