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

closing while QMenu in exec causes crash on macOS. Missing grab for mouse click focus?

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.8
    • GUI: Menus
    • None
    • macOS

    Description

      Issue closing parent window during QMenu contextmenu exec on macOS

      A non-modal QDialog contextmenu does not grab the mouse click focus on
      macOS when being opened unlike Linux and Windows

      This allows a user to leave an open contextmenu and close the MainWindow
      by hitting the x on the MainWindow title bar, resulting in a crash

      To recreate this bug on macOS:

      unzip bug.zip
      cd bug
      qmake
      make
      open ./bug.app

      In the smaller QDialog, launch its contextmenu by left clicking.
      While the menu is *open*, move mouse and hit the red X in the
      MainWindow titlebar. The app will crash.

      See:

      https://www.qtcentre.org/threads/65046-closing-parent-widget-during-QMenu-exec()

      link title Dated: Jan 2016

      The macOS platform should act just like Windows and Linux here and grab mouse click
      focus so that any mouse click on the titlebar of the MainWindow close X will simply close
      the open contextmenu.

      The only workaround is to use a QPointer<QMenu> here to detect that
      the menu was actually already destroyed.

      As far as I know this bug exists in all version of Qt since January 2016 timeframe.

      Attached a standalone test case for macOS. Same test case works just fine on Linux and Windows.

      Attachments

        Issue Links

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              kevinhendricks Kevin B. Hendricks
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: