diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index c53b028a44..2a7c58c4ee 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -102,7 +102,7 @@ def create_project( try: # Validate created project document validate(project_doc) - except Exception as exc: + except Exception: # Remove project if is not valid database[project_name].delete_one({"type": "project"}) raise diff --git a/openpype/tools/project_manager/project_manager/style/__init__.py b/openpype/tools/project_manager/project_manager/style/__init__.py index 6fd7d304cb..b686967ddd 100644 --- a/openpype/tools/project_manager/project_manager/style/__init__.py +++ b/openpype/tools/project_manager/project_manager/style/__init__.py @@ -79,7 +79,10 @@ class ResourceCache: def load_stylesheet(): - from . import rc_resources + from . import qrc_resources + + qrc_resources.qInitResources() + current_dir = os.path.dirname(os.path.abspath(__file__)) style_path = os.path.join(current_dir, "style.css") with open(style_path, "r") as style_file: diff --git a/openpype/tools/project_manager/project_manager/style/pyqt5_resources.py b/openpype/tools/project_manager/project_manager/style/pyqt5_resources.py index 34b6551210..bb26221a46 100644 --- a/openpype/tools/project_manager/project_manager/style/pyqt5_resources.py +++ b/openpype/tools/project_manager/project_manager/style/pyqt5_resources.py @@ -8,6 +8,7 @@ from PyQt5 import QtCore + qt_resource_data = b"\ \x00\x00\x00\xa5\ \x89\ @@ -37,6 +38,7 @@ qt_resource_data = b"\ \x44\xae\x42\x60\x82\ " + qt_resource_name = b"\ \x00\x08\ \x06\xc5\x8e\xa5\ @@ -58,6 +60,7 @@ qt_resource_name = b"\ \x00\x73\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\ " + qt_resource_struct_v1 = b"\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ @@ -66,6 +69,7 @@ qt_resource_struct_v1 = b"\ \x00\x00\x00\x52\x00\x00\x00\x00\x00\x01\x00\x00\x00\xa9\ " + qt_resource_struct_v2 = b"\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x00\x00\x00\ @@ -79,6 +83,7 @@ qt_resource_struct_v2 = b"\ \x00\x00\x01\x76\x41\x9d\xa2\x35\ " + qt_version = [int(v) for v in QtCore.qVersion().split('.')] if qt_version < [5, 8, 0]: rcc_version = 1 @@ -87,8 +92,10 @@ else: rcc_version = 2 qt_resource_struct = qt_resource_struct_v2 + def qInitResources(): QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + def qCleanupResources(): QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) diff --git a/openpype/tools/project_manager/project_manager/style/pyside2_resources.py b/openpype/tools/project_manager/project_manager/style/pyside2_resources.py index ecd5e7fa52..a8a368601d 100644 --- a/openpype/tools/project_manager/project_manager/style/pyside2_resources.py +++ b/openpype/tools/project_manager/project_manager/style/pyside2_resources.py @@ -5,6 +5,7 @@ from PySide2 import QtCore + qt_resource_data = b"\ \x00\x00\x00\xa5\ \x89\ @@ -34,6 +35,7 @@ HYs\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\ D\xaeB`\x82\ " + qt_resource_name = b"\ \x00\x08\ \x06\xc5\x8e\xa5\ @@ -55,6 +57,7 @@ qt_resource_name = b"\ \x00s\x00a\x00b\x00l\x00e\x00d\x00.\x00p\x00n\x00g\ " + qt_resource_struct = b"\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x00\x00\x00\ @@ -68,8 +71,10 @@ qt_resource_struct = b"\ \x00\x00\x01vA\x9d\xa25\ " + def qInitResources(): QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + def qCleanupResources(): QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) diff --git a/openpype/tools/project_manager/project_manager/style/qrc_resources.py b/openpype/tools/project_manager/project_manager/style/qrc_resources.py new file mode 100644 index 0000000000..be859cae46 --- /dev/null +++ b/openpype/tools/project_manager/project_manager/style/qrc_resources.py @@ -0,0 +1,25 @@ +import Qt + + +initialized = False +resources = None +if Qt.__binding__ == "PySide2": + from . import pyside2_resources as resources +elif Qt.__binding__ == "PyQt5": + from . import pyqt5_resources as resources + + +def qInitResources(): + global resources + global initialized + if resources is not None and not initialized: + initialized = True + resources.qInitResources() + + +def qCleanupResources(): + global resources + global initialized + if resources is not None: + initialized = False + resources.qCleanupResources() diff --git a/openpype/tools/project_manager/project_manager/style/rc_resources.py b/openpype/tools/project_manager/project_manager/style/rc_resources.py deleted file mode 100644 index 19dcda9564..0000000000 --- a/openpype/tools/project_manager/project_manager/style/rc_resources.py +++ /dev/null @@ -1,12 +0,0 @@ -import Qt - - -resources = None -if Qt.__binding__ == "PySide2": - from . import pyside2_resources as resources -elif Qt.__binding__ == "PyQt5": - from . import pyqt5_resources as resources - - -if resources is not None: - resources.qInitResources()