https://bugs.kde.org/show_bug.cgi?id=401069
Bug ID: 401069 Summary: KTextEditor: aboutToShowContextMenu is emitted for all open documents Product: frameworks-ktexteditor Version: unspecified Platform: Compiled Sources OS: All Status: REPORTED Severity: normal Priority: NOR Component: general Assignee: kwrite-bugs-n...@kde.org Reporter: rjvber...@gmail.com Target Milestone: --- SUMMARY A window (and in general, an application) can only show a single context menu at a time. Yet aboutToShowContextMenu is emitted for all currently open documents, not just the one that will show the menu. This leads to duplicate menu items in KDevelop, but curiously only when the CTags plugin is loaded. STEPS TO REPRODUCE 1. build KTextEditor with the following debug traces: 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; } } } 2. install Kate with the patch from D16779 2. run kate or kdevelop with multiple documents open OBSERVED RESULT In kate I'm seeing "NOT emitting" output for all open documents that aren't active: void KTextEditor::ViewPrivate::aboutToShowContextMenu() NOT emitting contextMenuAboutToShow for background view KTextEditor::ViewPrivate(0x7fa76e13ae30) void KTextEditor::ViewPrivate::aboutToShowContextMenu() NOT emitting contextMenuAboutToShow for background view KTextEditor::ViewPrivate(0x7fa76e69a280) void KTextEditor::ViewPrivate::aboutToShowContextMenu() emitting contextMenuAboutToShow for foreground view KTextEditor::ViewPrivate(0x7fa76e10c0e0) In KDevelop I'm seeing the same kind of output: void KTextEditor::ViewPrivate::aboutToShowContextMenu() NOT emitting contextMenuAboutToShow for background view KTextEditor::ViewPrivate(0x7fd5bb2f87e0) void KTextEditor::ViewPrivate::aboutToShowContextMenu() NOT emitting contextMenuAboutToShow for background view KTextEditor::ViewPrivate(0x7fd5bbb4c470) void KTextEditor::ViewPrivate::aboutToShowContextMenu() emitting contextMenuAboutToShow for foreground view KTextEditor::ViewPrivate(0x7fd5bb7eb830) but only for the documents that have been active (and/or have had the context menu open). See also https://phabricator.kde.org/D16882 -- You are receiving this mail because: You are watching all bug changes.