Bug 376693 - QAction objects passed to ContextMenuExtension are leaked
Summary: QAction objects passed to ContextMenuExtension are leaked
Status: RESOLVED FIXED
Alias: None
Product: kdevplatform
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-20 02:00 UTC by Friedrich W. H. Kossebau
Modified: 2017-07-22 12:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.2.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Friedrich W. H. Kossebau 2017-02-20 02:00:30 UTC
Many plugins create QAction objects on the fly in their implementation of the IPlugin::contextMenuExtension() method and then pass on those inside the returned ContextMenuExtension and forget about them. Just, as the ownership is not specified, callers of the IPlugin::contextMenuExtension() API do not take lifetime responsibility themselves for the QAction objects (and QMenu objects).

With noone caring... objects are leaking and accumulating.

On a first look I could not find a simple solution, so for now noting here.

Things to consider:
* Some plugins also pass existing QAction items which are in used elsewhere, e.g. in the toplevel menu. So simply deleting any QAction objects on destruction of the ContextMenuExtension instance does not work. Might work to just delete objects without a parent.
* More, ContextMenuExtension is currently passed by value and is not explicitely sharing data, so there are many copies of the lists with the pointers to the QAction objects
* The menus filled by the ContextMenuExtension in the API users might have a longer lifetime than the ContextMenuExtension objects, that needs some work as well.