kwidgetsaddons on OS X: menus become menu items

René J.V. Bertin rjvbertin at gmail.com
Fri Dec 11 22:55:35 UTC 2015


Hi,

After building kate I'm seeing repeating messages like the ones below on the calling terminal, using either Kate or KWrite. This also happens with Christoph's bundle(d) build. (I've patched my Qt build to be more informative though).

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"

>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 becoming a (toplevel) menu of their own.
Evidently it is too late to figure out why this happens at the time the warning is printed.

Qt has long had a "feature" in its menu item handling on OS X where it would guess the menuRole from the action text. That feature is intended to let certain QActions become "menu items" in the menu that's supposed to hold them on OS X, without requiring any action from the developer. So a QAction called Preferences, Settings or matching a few other patterns will go into the "Application menu" rather than into the menu the application is expecting, and be called Preferences.
There is only 1 way around this: call setMenuRole(QAction::NoRole) on each QAction before it can be added to a menu, or use the intended MenuRole for QActions. 

Either way, I have been trying set QAction::NoRole in a number of places that seemed relevant (up to the KActionMenu ctors), to no avail. The "Clipboard History" menu is present in the Edit menu where it is actually not out of place (and is functional), but the Bookmarks menu is nowhere to be found.

I could use a hand with this. If no better solution can be found I'd prefer deactivating the corresponding features (on OS X) rather than getting this terminal pollution and possible application instability (I've already seen cases where the menus wouldn't open).

Thanks,
René


More information about the Kde-frameworks-devel mailing list