Skip to content

Commit

Permalink
Add maya.pipeline.get_main_window
Browse files Browse the repository at this point in the history
Remove duplicated main window getting code
  • Loading branch information
davidlatwe committed Nov 6, 2019
1 parent 5907a80 commit 49687fe
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions avalon/maya/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ def find_host_config(config):
return config


def get_main_window():
"""Acquire Maya's main window"""
if self._parent is None:
self._parent = {
widget.objectName(): widget
for widget in QtWidgets.QApplication.topLevelWidgets()
}["MayaWindow"]
return self._parent


def uninstall(config):
"""Uninstall Maya-specific functionality of avalon-core.
Expand Down Expand Up @@ -250,10 +260,7 @@ def reload_pipeline(*args):
module = importlib.import_module(module)
reload(module)

self._parent = {
widget.objectName(): widget
for widget in QtWidgets.QApplication.topLevelWidgets()
}["MayaWindow"]
get_main_window()

import avalon.maya
api.install(avalon.maya)
Expand Down Expand Up @@ -625,10 +632,7 @@ def _on_maya_initialized(*args):
return

# Keep reference to the main Window, once a main window exists.
self._parent = {
widget.objectName(): widget
for widget in QtWidgets.QApplication.topLevelWidgets()
}["MayaWindow"]
get_main_window()


def _on_scene_new(*args):
Expand Down

0 comments on commit 49687fe

Please sign in to comment.