Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-818

QMenu created in python and attached to mainWindow crashes on shutdown

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P2: Important
    • None
    • 5.11.1, 5.11.2
    • PySide, Shiboken
    • None
    • Windows

    Description

      If a QMenu is created in Python and added to the QMainWindow, the application will crash on close if the menu was brought up when the application was running. The crash exhibits itself on Windows, but not on Mac.  Qt 5.11.1 was used when encountering this bug.

      This appears to be an issue of object ownership between Python and C++.

      This can be reproduced using the scriptableApplication example.

      • Build and run scriptableApplication
      • Paste the following Python code to the editor window:
      from PySide2.QtWidgets import *
      menuBar = mainWindow.menuBar()
      crashMenu = QMenu("Crash")
      mainWindow.actionCrash = crashMenu.addAction("Crash")
      menuBar.addMenu(crashMenu)
      • Click the Run toolbar button.
        The Crash menu will show up in the application.
      • Open the crash menu (no need to click on the menu item, just bring up the menu)
      • Quit the application.

      On Quit, the application will crash.

      A workaround for this is to have the QMenu created in C++ by calling crashMenu = mainWindow.addMenu("Crash") first, before crashMenu is filled out.

      Attachments

        1. pyside818.py
          1 kB
        2. PYSIDE-818-bug.gif
          PYSIDE-818-bug.gif
          1.21 MB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            kkyzivat Keith Kyzivat
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes