<table><tr><td style="">rjvbb created this revision.<br />rjvbb added a reviewer: KDevelop.<br />rjvbb added a project: KDevelop.<br />rjvbb requested review of this revision.
</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>REVISION SUMMARY</strong><div><p><tt style="background: #ebebeb; font-size: 13px;">TextDocument::populateContextMenu()</tt> is called when the user opens the contextmenu 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.</p>
<p>This patch prevents the consequence of calling <tt style="background: #ebebeb; font-size: 13px;">populateContextMenu()</tt> 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 <tt style="background: #ebebeb; font-size: 13px;">d->addedContextMenu</tt> from the target <tt style="background: #ebebeb; font-size: 13px;">menu</tt>.</p>
<p>Preventing the multiple calls might also be possible but would probably introduce more complexity (connecting and disconnecting <tt style="background: #ebebeb; font-size: 13px;">populateContextMenu()</tt> in reaction to <tt style="background: #ebebeb; font-size: 13px;">focusIn</tt> and <tt style="background: #ebebeb; font-size: 13px;">focusOut</tt> signals?).</p>
<p>This issue can be triggered by loading the Kate CTags plugin (after applying <a href="https://phabricator.kde.org/D16779" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D16779</a>). For an as-yet unknown reason <tt style="background: #ebebeb; font-size: 13px;">populateContextMenu()</tt> will be called with every view in which the contextmenu has been opened when the CTags plugin is loaded. A bug in KTextEditor maybe?</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>1- apply <a href="https://phabricator.kde.org/D16779" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D16779</a> to Kate, rebuild and reinstall the kate-ctags plugin<br />
2- load that plugin in KDevelop; observe contextmenu action duplication (once for each document that has opened a contextmenu)<br />
3- apply this patch, rebuild and reinstall libKDevPlatformShell<br />
4- repeat 2, contextmenu is free of duplicates</p></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>AFFECTED FILES</strong><div><div>kdevplatform/shell/textdocument.cpp</div></div></div><br /><div><strong>To: </strong>rjvbb, KDevelop<br /><strong>Cc: </strong>kde-frameworks-devel, kdevelop-devel, glebaccon, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd<br /></div>