<table><tr><td style="">rjvbb added a comment.
</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><div><blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">Please, let's find the root causes and fix things at the base instead of adding such</pre></div></blockquote>

<p>I suck at debugging event-driven code, unfortunately. But even if "we" find a fixable bug in some framework there's still no guarantee that no one will ever run KDevelop against a non-fixed version of that framework.</p>

<p>I'll see if a breakpoint in and backtrace from my added if teaches me anything but I have my doubts (and no other ideas).</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">(even uncommented=unexplained=surprising)</pre></div></blockquote>

<p>That's easy to fix. See the "todo" comment elsewhere in the same file.<br />
TBH, I didn't add a comment yet because in itself I see nothing wrong in checking if you're dealing with the active view before you start adding things to a contextmenu.</p>

<p>Ultimately the problem lies in having a single contextmenu (the <tt style="background: #ebebeb; font-size: 13px;">menu</tt> argument) and a <tt style="background: #ebebeb; font-size: 13px;">d->addedContextMenu</tt> per document (view). As I said on the ML, moving <tt style="background: #ebebeb; font-size: 13px;">populateContextMenu()</tt> and <tt style="background: #ebebeb; font-size: 13px;">addedContextMenu</tt> to a class like KDevelop::MainWindow would solve the issue too without having to rewrite <tt style="background: #ebebeb; font-size: 13px;">populateContextMenu()</tt>. There can only be a single contextmenu active at any time, so it would make sense to populate it in a singleton class, no?</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>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>