From e91dac7639877939599d1496467b227adc7628b2 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 14:35:22 +0100 Subject: [PATCH 1/4] renamed 'application' function to 'qt_app_context' --- openpype/tools/utils/lib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openpype/tools/utils/lib.py b/openpype/tools/utils/lib.py index aad00f886c..80299b9c63 100644 --- a/openpype/tools/utils/lib.py +++ b/openpype/tools/utils/lib.py @@ -22,7 +22,7 @@ def format_version(value, hero_version=False): @contextlib.contextmanager -def application(): +def qt_app_context(): app = QtWidgets.QApplication.instance() if not app: @@ -34,6 +34,9 @@ def application(): print("Using existing QApplication..") yield app +# Backwards compatibility +application = qt_app_context + class SharedObjects: jobs = {} From 1ddb7273f9a21dd6a22843619679732e28c35808 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 14:35:33 +0100 Subject: [PATCH 2/4] fixed imports in workfiles tool --- openpype/tools/workfiles/app.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/openpype/tools/workfiles/app.py b/openpype/tools/workfiles/app.py index 1679a18241..138c701176 100644 --- a/openpype/tools/workfiles/app.py +++ b/openpype/tools/workfiles/app.py @@ -10,9 +10,11 @@ import Qt from Qt import QtWidgets, QtCore from avalon import style, io, api, pipeline -from avalon.tools import lib as tools_lib -from avalon.tools.widgets import AssetWidget -from avalon.tools.delegates import PrettyTimeDelegate +from openpype.tools.utils.lib import ( + schedule, qt_app_context +) +from openpype.tools.utils.widgets import AssetWidget +from openpype.tools.utils.delegates import PrettyTimeDelegate from .model import ( TASK_NAME_ROLE, @@ -786,7 +788,7 @@ class FilesWidget(QtWidgets.QWidget): self.files_model.refresh() if self.auto_select_latest_modified: - tools_lib.schedule(self._select_last_modified_file, 100) + schedule(self._select_last_modified_file, 100) def on_context_menu(self, point): index = self.files_view.indexAt(point) @@ -1023,10 +1025,10 @@ class Window(QtWidgets.QMainWindow): def on_task_changed(self): # Since we query the disk give it slightly more delay - tools_lib.schedule(self._on_task_changed, 100, channel="mongo") + schedule(self._on_task_changed, 100, channel="mongo") def on_asset_changed(self): - tools_lib.schedule(self._on_asset_changed, 50, channel="mongo") + schedule(self._on_asset_changed, 50, channel="mongo") def on_file_select(self, filepath): asset_docs = self.assets_widget.get_selected_assets() @@ -1181,7 +1183,7 @@ def show(root=None, debug=False, parent=None, use_context=True, save=True): api.Session["AVALON_ASSET"] = "Mock" api.Session["AVALON_TASK"] = "Testing" - with tools_lib.application(): + with qt_app_context(): window = Window(parent=parent) window.refresh() From 62e04fb806a828bda4f1174a3d35e31c091b1e42 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 14:40:19 +0100 Subject: [PATCH 3/4] fix application function usage in look assigner --- openpype/tools/mayalookassigner/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/tools/mayalookassigner/app.py b/openpype/tools/mayalookassigner/app.py index 0f5a930902..d723387f2d 100644 --- a/openpype/tools/mayalookassigner/app.py +++ b/openpype/tools/mayalookassigner/app.py @@ -7,7 +7,7 @@ from Qt import QtWidgets, QtCore from openpype.hosts.maya.api.lib import assign_look_by_version from avalon import style, io -from avalon.tools import lib +from openpype.tools.utils.lib import qt_app_context from maya import cmds # old api for MFileIO @@ -258,7 +258,7 @@ def show(): mainwindow = next(widget for widget in top_level_widgets if widget.objectName() == "MayaWindow") - with lib.application(): + with qt_app_context(): window = App(parent=mainwindow) window.setStyleSheet(style.load_stylesheet()) window.show() From aee9ebeef9d6a59ab423851455b3c8f6675919d8 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 16:02:53 +0100 Subject: [PATCH 4/4] fix hound --- openpype/tools/utils/lib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openpype/tools/utils/lib.py b/openpype/tools/utils/lib.py index 80299b9c63..a7c771b297 100644 --- a/openpype/tools/utils/lib.py +++ b/openpype/tools/utils/lib.py @@ -34,6 +34,7 @@ def qt_app_context(): print("Using existing QApplication..") yield app + # Backwards compatibility application = qt_app_context