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)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.1, 5.9.3
    • 5.1.1, 5.2.0 Beta1
    • GUI: Window management
    • None
    • OS X 10.8.5
    • macOS
    • 09acf326dbc6b7b67f21a360be8c91605ce47f1e

    Description

      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.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes