mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Cleanup OpenPype Qt widgets on Substance Painter shutdown
This commit is contained in:
parent
82639e8634
commit
c101f6a2cb
1 changed files with 22 additions and 1 deletions
|
|
@ -1,13 +1,34 @@
|
|||
|
||||
|
||||
def cleanup_openpype_qt_widgets():
|
||||
"""
|
||||
Workaround for Substance failing to shut down correctly
|
||||
when a Qt window was still open at the time of shutting down.
|
||||
|
||||
This seems to work sometimes, but not all the time.
|
||||
|
||||
"""
|
||||
# TODO: Create a more reliable method to close down all OpenPype Qt widgets
|
||||
from PySide2 import QtWidgets
|
||||
import substance_painter.ui
|
||||
|
||||
# Kill OpenPype Qt widgets
|
||||
print("Killing OpenPype Qt widgets..")
|
||||
for widget in QtWidgets.QApplication.topLevelWidgets():
|
||||
if widget.__module__.startswith("openpype."):
|
||||
print(f"Deleting widget: {widget.__class__.__name__}")
|
||||
substance_painter.ui.delete_ui_element(widget)
|
||||
|
||||
|
||||
def start_plugin():
|
||||
from openpype.pipeline import install_host
|
||||
from openpype.hosts.substancepainter.api import SubstanceHost
|
||||
|
||||
install_host(SubstanceHost())
|
||||
|
||||
|
||||
def close_plugin():
|
||||
from openpype.pipeline import uninstall_host
|
||||
cleanup_openpype_qt_widgets()
|
||||
uninstall_host()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue