Commit faec535829a0e454a6784b0c5c37cb63e7da8f73

  • avatar
  • Prasanth Ullattil <prasanth.ulattil @no…a.com>
  • Fri Sep 18 13:38:26 CEST 2009
Application crashes when a menu is inserted twice on a menubar (Cocoa).

Cocoa does not allow NSMenu to have multiple supermenu's. If a menu is
added again as submenu, Qt will now disable the menu item or the menu
will not be added at all if it is added again to the menubar.

Task-number: 258822
Reviewed-by: MortenS
  
13021302 do not support the signals: aboutToHide (), aboutToShow () and hovered ().
13031303 It is not possible to display an icon in a native menu on Windows Mobile.
13041304
1305 \section1 QMenu on Mac OS X with Qt build against Cocoa
1306
1307 QMenu can be inserted only once in a menu/menubar. Subsequent insertions will
1308 have no effect or will result in a disabled menu item.
1309
13051310 See the \l{mainwindows/menus}{Menus} example for an example of how
13061311 to use QMenuBar and QMenu in your application.
13071312
  
14121412 GetMenuItemProperty(action->menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(caused), 0, &caused);
14131413 SetMenuItemProperty(data.submenuHandle, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), &caused);
14141414#else
1415 [item setSubmenu:static_cast<NSMenu *>(action->action->menu()->macMenu())];
1415 NSMenu *subMenu = static_cast<NSMenu *>(action->action->menu()->macMenu());
1416 if ([subMenu supermenu] != nil) {
1417 // The menu is already a sub-menu of another one. Cocoa will throw an exception,
1418 // in such cases. For the time being, a new QMenu with same set of actions is the
1419 // only workaround.
1420 action->action->setEnabled(false);
1421 } else {
1422 [item setSubmenu:subMenu];
1423 }
14161424#endif
14171425 } else { //respect some other items
14181426#ifndef QT_MAC_USE_COCOA
16861686 GetMenuItemProperty(action->menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(caused), 0, &caused);
16871687 SetMenuItemProperty(submenu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), &caused);
16881688#else
1689 [item setSubmenu:submenu];
1689 if ([submenu supermenu] != nil)
1690 return;
1691 else
1692 [item setSubmenu:submenu];
16901693#endif
16911694 }
16921695#ifndef QT_MAC_USE_COCOA