<table><tr><td style="">rjvbb edited the summary of this revision. <a href="https://phabricator.kde.org/transactions/detail/PHID-XACT-DREV-7w5nuwsstwrpreo/">(Show Details)</a><br />rjvbb edited the test plan for this revision. <a href="https://phabricator.kde.org/transactions/detail/PHID-XACT-DREV-7ecclnruy4l3tws/">(Show Details)</a><br />rjvbb set the repository for this revision to R32 KDevelop.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D16882">View Revision</a></tr></table><br /><div><strong>CHANGES TO REVISION SUMMARY</strong><div><div style="white-space: pre-wrap; color: #74777D;">`TextDocument::populateContextMenu()` is called when the user opens the contextmenu <span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">but this can happen for more than just the view currently active. When that happens, each view will add its own copy of the list of items to be added to the contextmenu, resulting in duplicate entries.<br />
<br />
This patch prevents the consequence of calling `populateContextMenu()` multiple times by checking if the target view is indeed the one currently active in the mainWindow that it belongs to, *after* removing the items from `d->addedContextMenu` from the target `menu`.<br />
<br />
Preventing the multiple calls might also be possible but would probably introduce more complexity (connecting and disconnecting `populateContextMenu()` in reaction to `focusIn` and `focusOut` signals?)</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">and intends to remove the menu items added in a previous invocation before adding an updated list of actions</span>.<br />
<br />
Th<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">is issue can be triggered by loading the Kate CTags plugin (after applying D16779). For an as-yet unknown reason `populateContextMenu()` will be called with every view in which the contextmenu has been opened when the CTags plugin is loaded.</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">at list of actions to remove has to be menu-specific;</span> <span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">A bug</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">it can be a static member variable since</span> in <span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">KTextEditor maybe?</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">practice there is only a single QMenu instance for the context menu.</span></div></div></div><br /><div><strong>CHANGES TO TEST PLAN</strong><div><div style="white-space: pre-wrap; color: #74777D;"><div style="padding: 8px 0;">...</div>2- <span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">apply D16927 to KTextEditor, rebuild, reinstall<br />
3- </span>load that plugin in KDevelop; observe contextmenu action duplication (once for each document that has opened a contextmenu)<br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">3</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">4</span>- apply this patch, rebuild and reinstall libKDevPlatformShell<br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">4</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">5</span>- repeat 2, contextmenu is free of duplicates</div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R32 KDevelop</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D16882">https://phabricator.kde.org/D16882</a></div></div><br /><div><strong>To: </strong>rjvbb, KDevelop, kossebau<br /><strong>Cc: </strong>kossebau, kde-frameworks-devel, kdevelop-devel, glebaccon, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd<br /></div>