Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PySide6 Crash upon exit after QUiLoader::load with custom widgets
Qt 6.11 is out! See what's new in the release blog

PySide6 Crash upon exit after QUiLoader::load with custom widgets

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Okko Willeboordse
    wrote on last edited by Okko Willeboordse
    #1

    Running PySide6 any version, Python 3.10/3.11 on Windows 11.

    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.

    1 Reply Last reply
    0
    • O Offline
      O Offline
      Okko Willeboordse
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        Okko Willeboordse
        wrote on last edited by
        #3

        Fixed, see; https://bugreports.qt.io/browse/PYSIDE-2222

        1 Reply Last reply
        0
        • ChronalC Offline
          ChronalC Offline
          Chronal
          wrote on last edited by
          #4

          It looks like this is a known issue with PySide6. You should try using the latest version of PySide6, which should fix the issue. You can also try using the Qt for Python 5.15.2 release, which should also fix the issue. If neither of those solutions work, then you should report the issue to the Qt for Python team.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved