Plugin causing duplicate entries in the document context menu

Kevin Funk kfunk at kde.org
Mon Nov 12 11:58:18 GMT 2018


On Monday, 12 November 2018 12:38:42 CET René J.V. Bertin wrote:
> Hi,

Hey,

> I've started to notice multiple copies of the context menu items provided by
> certain plugins since a few days, not sure when exactly this started, see
> the attached screenshot.
> 
> The issue appears when I load the CTags plugin I'm working on (D16779); each
> time I switch to another (already) open document the set of duplicate items
> gets another duplicate. The CTags submenu always remains at the top of the
> list.
> 
> Context menu generation is a little complicated so I haven't yet found a
> spot to put my finger on. It seems to have to do with the fact the plugin
> uses KXMLGui to manage it's menus(?).

Nope.

> Does anyone more familiar with the
> architecture have an idea what might be causing this or what I should be
> looking at?

The entry point for plugins to provide their context menus is 
KDevelop::IPlugin::contextMenuExtension.

Your screenshot indicates that e.g. the patchreview plugin is loaded twice(?). 
The "Review Patch" string is found in patchreview.cpp.

See there:

```
KDevelop::ContextMenuExtension 
PatchReviewPlugin::contextMenuExtension(KDevelop::Context* context, QWidget* 
parent)
{   
    //...
    
    if (urls.size() == 1) {
        QAction* reviewAction = new QAction( 
QIcon::fromTheme(QStringLiteral("text-x-patch")),
                                             i18n("Review Patch"), parent);
        reviewAction->setData(QVariant(urls[0]));
        connect( reviewAction, &QAction::triggered, this, 
&PatchReviewPlugin::executeFileReviewAction );
        ContextMenuExtension cm;
        cm.addAction( KDevelop::ContextMenuExtension::VcsGroup, reviewAction 
);
```

=> Check if and in that case why that `addAction(...)` is invoked twice.

Or something in PluginController::queryPluginsForContextMenuExtensions is 
wrong (or patched wrongly...).

Regards,
Kevin



> Unloading the CTags plugin does NOT stop the duplication
> process.
> 
> PS: I indeed set the tearOff bit in my build; that's an unrelated change
> that does not appear to cause this duplication issue.
> 
> Thanks for any pointers,
> R.


-- 
Kevin Funk | kfunk at kde.org | http://kfunk.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20181112/ece981ca/attachment.sig>


More information about the KDevelop-devel mailing list