Skip to content

ayon_plugin

cleanup_ayon_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.

Source code in client/ayon_substancepainter/deploy/plugins/ayon_plugin.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
def cleanup_ayon_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 AYON Qt widgets
    from qtpy import QtWidgets
    import substance_painter.ui

    # Kill AYON Qt widgets
    print("Killing AYON Qt widgets..")
    for widget in QtWidgets.QApplication.topLevelWidgets():
        if widget.__module__.startswith("ayon_"):
            print(f"Deleting widget: {widget.__class__.__name__}")
            substance_painter.ui.delete_ui_element(widget)