diff --git a/avalon/tools/creator/app.py b/avalon/tools/creator/app.py index 25c79c1d6..f67cb767a 100644 --- a/avalon/tools/creator/app.py +++ b/avalon/tools/creator/app.py @@ -555,37 +555,20 @@ def set_item(self, item): def show(debug=False, parent=None): - """Display asset creator GUI + """Display Asset Creator GUI Arguments: - debug (bool, optional): Run loader in debug-mode, - defaults to False + debug (bool, optional): Run loader in debug-mode, defaults to False parent (QtCore.QObject, optional): When provided parent the interface to this QObject. """ - if module.window: + try: module.window.close() - del(module.window) - - if debug: - from avalon import mock - for creator in mock.creators: - api.register_plugin(api.Creator, creator) - - import traceback - sys.excepthook = lambda typ, val, tb: traceback.print_last() - - io.install() - - any_project = next( - project for project in io.projects() - if project.get("active", True) is not False - ) - - api.Session["AVALON_PROJECT"] = any_project["name"] - module.project = any_project["name"] + del module.window + except (RuntimeError, AttributeError): + pass with lib.application(): window = Window(parent) diff --git a/avalon/tools/loader/app.py b/avalon/tools/loader/app.py index c3f5ca40f..94b71a4f1 100644 --- a/avalon/tools/loader/app.py +++ b/avalon/tools/loader/app.py @@ -388,37 +388,17 @@ def show(debug=False, parent=None, use_context=False): """Display Loader GUI Arguments: - debug (bool, optional): Run loader in debug-mode, - defaults to False + debug (bool, optional): Run loader in debug-mode, defaults to False parent (QtCore.QObject, optional): The Qt object to parent to. use_context (bool): Whether to apply the current context upon launch """ - # Remember window - if module.window is not None: - try: - module.window.show() - - # If the window is minimized then unminimize it. - if module.window.windowState() & QtCore.Qt.WindowMinimized: - module.window.setWindowState(QtCore.Qt.WindowActive) - - # Raise and activate the window - module.window.raise_() # for MacOS - module.window.activateWindow() # for Windows - module.window.refresh() - return - except RuntimeError as exc: - if not str(exc).rstrip().endswith("already deleted."): - raise - - # Garbage collected - module.window = None - - if debug: - import traceback - sys.excepthook = lambda typ, val, tb: traceback.print_last() + try: + module.window.close() + del module.window + except (RuntimeError, AttributeError): + pass with lib.application(): diff --git a/avalon/tools/projectmanager/app.py b/avalon/tools/projectmanager/app.py index 03069f5fc..ce8e465c4 100644 --- a/avalon/tools/projectmanager/app.py +++ b/avalon/tools/projectmanager/app.py @@ -243,8 +243,7 @@ def show(root=None, debug=False, parent=None): """Display Loader GUI Arguments: - debug (bool, optional): Run loader in debug-mode, - defaults to False + debug (bool, optional): Run loader in debug-mode, defaults to False parent (QtCore.QObject, optional): When provided parent the interface to this QObject. @@ -256,9 +255,6 @@ def show(root=None, debug=False, parent=None): except (RuntimeError, AttributeError): pass - if debug is True: - io.install() - with tools_lib.application(): window = Window(parent=parent) window.show() diff --git a/avalon/tools/sceneinventory/app.py b/avalon/tools/sceneinventory/app.py index 984f0302f..c8faa0d04 100644 --- a/avalon/tools/sceneinventory/app.py +++ b/avalon/tools/sceneinventory/app.py @@ -927,8 +927,7 @@ def show(root=None, debug=False, parent=None): """Display Scene Inventory GUI Arguments: - debug (bool, optional): Run in debug-mode, - defaults to False + debug (bool, optional): Run in debug-mode, defaults to False parent (QtCore.QObject, optional): When provided parent the interface to this QObject. @@ -940,10 +939,6 @@ def show(root=None, debug=False, parent=None): except (RuntimeError, AttributeError): pass - if debug: - import traceback - sys.excepthook = lambda typ, val, tb: traceback.print_last() - with tools_lib.application(): window = Window(parent) window.show() diff --git a/avalon/tools/workfiles/app.py b/avalon/tools/workfiles/app.py index 70c614de7..06e1ab85b 100644 --- a/avalon/tools/workfiles/app.py +++ b/avalon/tools/workfiles/app.py @@ -855,12 +855,22 @@ def _on_task_changed(self): def show(root=None, debug=False, parent=None, use_context=True): - """Show Work Files GUI""" + """Show Work Files GUI # todo: remove `root` argument to show() - if module.window: + Arguments: + root (str, optional): The root for the work files app + debug (bool, optional): Run in debug-mode, defaults to False + parent (QtCore.QObject, optional): When provided parent the interface + to this QObject. + + """ + + try: module.window.close() - del(module.window) + del module.window + except (RuntimeError, AttributeError): + pass host = api.registered_host() if host is None: @@ -882,10 +892,6 @@ def show(root=None, debug=False, parent=None, use_context=True): raise RuntimeError("Host is missing required Work Files interfaces: " "%s (host: %s)" % (", ".join(missing), host)) - if debug: - api.Session["AVALON_ASSET"] = "Mock" - api.Session["AVALON_TASK"] = "Testing" - with tools_lib.application(): window = Window(parent=parent)