https://bugs.kde.org/show_bug.cgi?id=356585
Bug ID: 356585 Summary: adding menu as submenu (too?) leads to repeated "InsertNative: item is already in menu" errors Product: frameworks-ktexteditor Version: unspecified Platform: Compiled Sources OS: OS X Status: UNCONFIRMED Severity: normal Priority: NOR Component: general Assignee: kwrite-bugs-n...@kde.org Reporter: rjvber...@gmail.com This was previously presented under a less appropriate title on the frameworks ML: When running kate5 or kwrite5 on OS X I'm seeing repeating messages like the ones below on the calling terminal: void QCocoaMenu::insertNative(QCocoaMenuItem *, QCocoaMenuItem *) Menu item "Clipboard &History" is already in menu "Edit" , remove it from the other menu first before inserting into "Untitled" void QCocoaMenu::insertNative(QCocoaMenuItem *, QCocoaMenuItem *) Menu item "&Bookmarks" is already in menu "" , remove it from the other menu first before inserting into "Untitled" virtual void QCocoaMenu::removeMenuItem(QPlatformMenuItem *) Item "Clipboard &History" to remove does not belong to this menu "Untitled" virtual void QCocoaMenu::removeMenuItem(QPlatformMenuItem *) Item "&Bookmarks" to remove does not belong to this menu "Untitled" void QCocoaMenu::insertNative(QCocoaMenuItem *, QCocoaMenuItem *) Menu item "Clipboard &History" is already in menu "Edit" , remove it from the other menu first before inserting into "Untitled" void QCocoaMenu::insertNative(QCocoaMenuItem *, QCocoaMenuItem *) Menu item "&Bookmarks" is already in menu "" , remove it from the other menu first before inserting into "Untitled" void QCocoaMenu::insertNative(QCocoaMenuItem *, QCocoaMenuItem *) Menu item "Clipboard &History" is already in menu "Edit" after item "" , remove it from the other menu first before inserting into "Edit" virtual void QCocoaMenu::removeMenuItem(QPlatformMenuItem *) Item "Clipboard &History" to remove does not belong to this menu "Untitled" virtual void QCocoaMenu::removeMenuItem(QPlatformMenuItem *) Item "&Bookmarks" to remove does not belong to this menu "Untitled" Stock Qt will print less informative messages; I've patched the indicated functions to include useful details. >From what I've been able to gather, this means that the 2 menus in question get added to another menu (the Edit menu for "Clipboard History") rather than being used exclusively as a (toplevel) menu of their own. Evidently it is too late to figure out exactly what happens at the time the warning is printed. NB: those are error messages; when printed they're the only action performed by the respective functions. Both menus appear in the edit view's context menu (as expected?) and the Clipboard History menu appears in the Edit menu of the global menubar. The Bookmarks menu however does not appear consistently, and when it does it is usually at the expense of another menu (the Tools menu though I cannot affirm that it is always that one). Reproducible: Always Steps to Reproduce: 1. Install kate on OS X 2. run it from a terminal, i.e. /path/to/kate.app/Contents/MacOS/kate Actual Results: An initial series of the messages above appears immediately; more are printed each time the actions in question are used one way or another. Expected Results: The menus should appear where expected without leading to error messages being printed on the terminal. The first-stop reaction on OS X when QActions get added to the wrong menu, setting their MenuRole to QAction::NoRole has no effect. Both menus are KActionMenu instances and thus derive from QWidgetAction . I think the following blurb from the QWidgetAction documentation is relevant here: "OS X: If you add a widget to a menu in the application's menu bar on OS X, the widget will be added and it will function but with some limitations: The widget is reparented away from the QMenu to the native menu view. If you show the menu in some other place (e.g. as a popup menu), the widget will not be there." Removing all references to m_pasteMenu and m_bookmarksMenu in the KTextEditor code has the expected effect of stopping the error messages, but is only a crude workaround that doesn't solve the underlying bug. It would be much more elegant to add these menus (and others, as a general rule) to only a single menu on OS X). I have not yet been able to figure out where that ought to be done -- in the framework or in Kate. I would appreciate some pointers allowing me to try to come up with a solution. Concerning the choice of what menu NOT to add them to: - context menus behave a lot more if not exactly as on Linux because managed purely and completely by Qt (including theming btw). - a Bookmarks menu doesn't look out of place in the toplevel menubar and is probably more useful in that visible/accessible position than in a context menu; it also has a role that is much less bound to cursor context. - the Clipboard History menu is more or less in the opposite situation; as something that leads to inserting text at the cursor location it makes more sense in a context menu. -- You are receiving this mail because: You are watching all bug changes.