Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-34160

OS X: adding QAction with submenu to more than one menu fails (regression from Qt 4)



    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.1.1, 5.2.0 Beta1
    • Fix Version/s: 5.6.1, 5.9.3
    • Component/s: GUI: Window management
    • Labels:
    • Environment:
      OS X 10.8.5
    • Platform/s:
    • Commits:


      when i create a QAction with an attached sub menu (via setMenu()) and add this to more than one QMenu, then the App emits errors and eventually the action is not added to the subsequent menus.

      The error message when adding the QAction to the 2nd menu is:
      void QCocoaMenu::insertNative(QCocoaMenuItem *, QCocoaMenuItem *) Menu item is already in a menu, remove it from the other menu first before inserting

      When adding the Menu to the Menubar the same error message is emitted again.

      When the App is closed, this error message is emitted:
      virtual void QCocoaMenu::removeMenuItem(QPlatformMenuItem *) Item to remove does not belong to this menu

      the attached example can be run in two ways:
      add QAction to filemenu, then to contextmenu
      or vice versa, if you swap code blocks 1 and 2 in mainwindow.cpp.

      if the QMenu is added to the filemenu first, then the submenu shows up in both filemenu and contextmenu.

      if the submenu is added to the contextmenu first, then it does not show up in the filemenu (and in this example, the entire filemenu does not show up because it is empty)

      In my actual Application error message 1 also showed up when closing the context menu for the first time but not on subsequent tries.

      In the test app showing the empty context menu also yields a 3rd error message:
      void QCocoaWindow::syncWindowState(Qt::WindowState) invalid window content view size, check your window geometry
      this does not happen in them main menu bar.


          Issue Links

          For Gerrit Dashboard: QTBUG-34160
          # Subject Branch Project Status CR V



              dedietri Gabriel de Dietrich (drgvond)
              kio Günter Woigk
              12 Vote for this issue
              22 Start watching this issue



                  Gerrit Reviews

                  There are no open Gerrit changes