<table><tr><td style="">rjvbb created this revision.<br />rjvbb added reviewers: KTextEditor, Frameworks.<br />rjvbb added a project: KTextEditor.<br />Herald added projects: Kate, Frameworks.<br />Herald added a subscriber: kwrite-devel.<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/D16927">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p><tt style="background: #ebebeb; font-size: 13px;">ViewPrivate::contextMenu()</tt> has a surprising way of handling the <tt style="background: #ebebeb; font-size: 13px;">ktexteditor_popup</tt> menu aboutToXXX signals: it disconnects them from the current ViewPrivate instance and then reconnects them to the same instance.</p>

<p>I think the disconnect should be from all receivers that were once connected to the menu show & hide signals. Doing that resolves the issue where <tt style="background: #ebebeb; font-size: 13px;">ViewPrivate::aboutToShowContextMenu()</tt> is called for all open KTextEditorViews that once had the context menu open, instead of only for the view that is currently active.</p>

<p>BUG: <a href="https://bugs.kde.org/show_bug.cgi?id=401069" class="remarkup-link" target="_blank" rel="noreferrer">https://bugs.kde.org/show_bug.cgi?id=401069</a></p></div></div><br /><div><strong>TEST PLAN</strong><div><p>Build KTextEditor with a debug trace to <tt style="background: #ebebeb; font-size: 13px;">ViewPrivate::aboutToShowContextMenu()</tt>, e.g.</p>

<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);">void KTextEditor::ViewPrivate::aboutToShowContextMenu()
{
    QMenu *menu = qobject_cast<QMenu *>(sender());

    if (menu) {
        if (mainWindow()->activeView() == this) {
            qWarning() << Q_FUNC_INFO << "emitting contextMenuAboutToShow for foreground view" << this;
            emit contextMenuAboutToShow(this, menu);
        } else {
            qWarning() << Q_FUNC_INFO << "NOT emitting contextMenuAboutToShow for background view" << this;
        }
    }
}</pre></div>

<p>Now open Kate with multiple documents. Right-click in the active document, notice only that view emits <tt style="background: #ebebeb; font-size: 13px;">contextMenuAboutToShow</tt>. Activate other documents one after the other, right-clicking in them, and notice how the previously active documents would have emitted the <tt style="background: #ebebeb; font-size: 13px;">contextMenuAboutToShow</tt> signal.</p>

<p>This is resolved by applying this patch. Opening the context menu in a long-running multi-document session keeps feeling snappier during the entire session too.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R39 KTextEditor</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D16927">https://phabricator.kde.org/D16927</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/view/kateview.cpp</div></div></div><br /><div><strong>To: </strong>rjvbb, KTextEditor, Frameworks<br /><strong>Cc: </strong>kde-frameworks-devel, kwrite-devel, michaelh, ngraham, bruns, demsking, head7, cullmann, kfunk, sars, dhaumann<br /></div>