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.