D16927: KTextEditor : disconnect contextmenu from all aboutToXXContextMenu receivers
René J.V. Bertin
noreply at phabricator.kde.org
Fri Nov 16 16:24:29 GMT 2018
rjvbb created this revision.
rjvbb added reviewers: KTextEditor, Frameworks.
rjvbb added a project: KTextEditor.
Herald added projects: Kate, Frameworks.
Herald added a subscriber: kwrite-devel.
rjvbb requested review of this revision.
REVISION SUMMARY
`ViewPrivate::contextMenu()` has a surprising way of handling the `ktexteditor_popup` menu aboutToXXX signals: it disconnects them from the current ViewPrivate instance and then reconnects them to the same instance.
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 `ViewPrivate::aboutToShowContextMenu()` is called for all open KTextEditorViews that once had the context menu open, instead of only for the view that is currently active.
BUG: https://bugs.kde.org/show_bug.cgi?id=401069
TEST PLAN
Build KTextEditor with a debug trace to `ViewPrivate::aboutToShowContextMenu()`, e.g.
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;
}
}
}
Now open Kate with multiple documents. Right-click in the active document, notice only that view emits `contextMenuAboutToShow`. Activate other documents one after the other, right-clicking in them, and notice how the previously active documents would have emitted the `contextMenuAboutToShow` signal.
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.
REPOSITORY
R39 KTextEditor
REVISION DETAIL
https://phabricator.kde.org/D16927
AFFECTED FILES
src/view/kateview.cpp
To: rjvbb, #ktexteditor, #frameworks
Cc: kde-frameworks-devel, kwrite-devel, michaelh, ngraham, bruns, demsking, head7, cullmann, kfunk, sars, dhaumann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kwrite-devel/attachments/20181116/eeffa36c/attachment-0001.html>
More information about the KWrite-Devel
mailing list