Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Edit: I have the same error without my virtualenv with Qt.py and using directly PySide2.
Copy link to clipboard
Copied
More information:
Version 7.1.1 (but also tested on version 7.2) and platform Windows 10 64bits.
Copy link to clipboard
Copied
Hello,
We also have this crash when we parent a QWidget to Substance Painter MainWindow:
"""
Parenting a QWidget to the substance main window makes the next Painter instance to raise an error
"""
import substance_painter
from PySide2 import QtWidgets
PLUGIN_WIDGETS = []
def display_dialog():
main_window = substance_painter.ui.get_main_window()
dialog = QtWidgets.QDialog(parent=main_window) # Here
dialog.exec_()
def start_plugin():
global PLUGIN_WIDGETS
menu = QtWidgets.QMenu("&Test Menu")
action = 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 = None
if __name__ == "__main__":
start_plugin()
Copy link to clipboard
Copied
I am also suffering from the same phenomenon.
Has it been resolved?
Copy link to clipboard
Copied
I am experiencing this as well. What is the suggested solution? Thanks!
Copy link to clipboard
Copied
We've spent more time looking into this and found that adding the following line resolves the issue:
dialog.setAttribute(QtGui.Qt.WA_DeleteOnClose)