Painter crashes on startup - python plugin delete_ui_element
Hello,
I'm writing a Python plugin for Substance Painter and I discover a bug that creates crash on startup:
I have a virtualenv containing these versions:
PySide2==5.12.5
Qt.py==1.3.3
shiboken2==5.12.5
I add virtualenv's site-packages to my PYTHONPATH and launch Painter with this script inside startup folder :
from Qt import QtWidgets
import substance_painter
PLUGIN_WIDGETS = []
def display_dialog():
main_window = substance_painter.ui.get_main_window()
dialog = QtWidgets.QDialog(main_window)
dialog.show()
def start_plugin():
global PLUGIN_WIDGETS
menu = QtWidgets.QMenu("&Test Menu")
action = unit_menu.addAction("Test")
action.triggered.connect(display_dialog)
substance_painter.ui.add_menu(menu)
PLUGIN_WIDGETS.append(menu)
def close_plugin():
global PLUGIN_WIDGETS
for widget in PLUGIN_WIDGETS:
substance_painter.ui.delete_ui_element(widget)
PLUGIN_WIDGETS = []
I just add a menu "Test" with a "test" action inside and the action open an empty dialog linked to Painter's main window.
When I click on the action to display the dialog, the dialog is correctly shown. But, if I restart Painter just after, I have a crash on startup without message on log files and Painter starts on "Report" window's close.
To fix it, I append my dialog to "PLUGIN_WIDGETS" to delete it on plugin close. It works for this small plugin, but I can't do it for all widgets created in bigger plugins (I will add more complicated Python scripts used also in other software).
Is there another way to prevent this startup crash? Is this bug normal?
Thanks in advance!
Coralie Goldbaum.
