Proper lifetime support for one-time menu objects with contextMenuExtension

Authored by kossebau on Jul 18 2017, 2:27 AM.

Description

Proper lifetime support for one-time menu objects with contextMenuExtension

Summary:
For actions and submenus created only for the given context for the menu,
as opposed to persistent context-ignorant actions kept around all the time
and owned by the plugin instance, in IPlugin::contextMenuExtension()
overrides was no access to a QObject/QWidget element which could be used
as QObject-style memory management for the given context menu event.
So the old code for that either used instances like the plugin objects
themselves or even none at all, which both de-facto results in
accumulating lots of out-of-use QActions and QMenus during the runtime
of KDevelop, only to be cleaned up either on destruction of the plugin
instances at process end or never.

Passing to IPlugin::contextMenuExtension a QWidget* object to be used
as memory management parent matching the lifetime of the context menu
allows to fix that.

Test Plan:
Invoked the context menus changed by the patch, and the temporarily
added slots connected to QObject::destroyed handlers of the
per-context-menu QAction & QMenu objects were invoked at the right time.
No new crashes seen.

Reviewers: KDevelop, kfunk

Reviewed By: KDevelop, kfunk

Subscribers: kfunk, kdevelop-devel

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

Details

Committed
kossebauJul 21 2017, 11:19 PM
Reviewer
KDevelop
Differential Revision
D6769: Proper lifetime support for one-time menu objects with contextMenuExtension
Parents
R32:90b8eca2b81f: Remove unused argument
Branches
Unknown
Tags
Unknown