Details
Description
Running PySide6 any version, Python 3.10/3.11 on Windows 11/Debian 11.6.
Running the example code, as is, as can be found in;
https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html#option-b-loading-it-directly
i.e. copy/paste example code in main.py and mainwindow.ui
main.py crashes upon exit when the 'custom widget' mechanism is used.
For the 'custom widget' mechanism refer to;
https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html#custom-widgets-in-qt-designer
To deploy the custom widget mechanism do the following;
- Add a PYSIDE_DESIGNER_PLUGINS environment variable and set it with the path to a folder holding,
- a register*.py file (can be empty) holding the custom widget registration code
main.py now crashes upon exit. Post mortem analysis reveals;
Unhandled exception thrown: read access violation. tstate was nullptr. > python311.dll!import_get_module(_ts * tstate, _object * name) Line 314 python311.dll!PyImport_GetModule(_object * name) Line 1764 python311.dll!wait_for_thread_shutdown(_ts * tstate) Line 2894 python311.dll!Py_FinalizeEx() Line 1767
Without the environment variable or register*.py file or both, main.py does not crash.
With PySide2, main.py does not crash.
Can this be caused by the PySidePlugin.dll.PyDesignerCustomWidgets::PyDesignerCustomWidgets which does a Py_Initialize?
This is fine in an application embedding Python, i.e. Qt Designer but not in a Python interpreter, i.e. in a Python script.