Skip to content

Commit

Permalink
Merge pull request #486 from BigRoy/fix485
Browse files Browse the repository at this point in the history
Fix #485: Allow avalon to initialize correctly with Maya 2020
  • Loading branch information
BigRoy authored Dec 16, 2019
2 parents a7a6941 + 54377ef commit 8369285
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions avalon/maya/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import contextlib

from maya import cmds, OpenMaya
import maya.utils
import maya.api.OpenMaya as om
from pyblish import api as pyblish

Expand Down Expand Up @@ -205,7 +206,11 @@ def deferred():
command=interactive.reset_resolution)

# Allow time for uninstallation to finish.
QtCore.QTimer.singleShot(100, deferred)
# We use Maya's executeDeferred instead of QTimer.singleShot
# so that it only gets called after Maya UI has initialized too.
# This is crucial with Maya 2020+ which initializes without UI
# first as a QCoreApplication
maya.utils.executeDeferred(deferred)


def launch_workfiles_app(*args):
Expand Down Expand Up @@ -267,8 +272,14 @@ def reload_pipeline(*args):


def _uninstall_menu():
app = QtWidgets.QApplication.instance()
widgets = dict((w.objectName(), w) for w in app.allWidgets())

# In Maya 2020+ don't use the QApplication.instance()
# during startup (userSetup.py) as it will return a
# QtCore.QCoreApplication instance which does not have
# the allWidgets method. As such, we call the staticmethod.
all_widgets = QtWidgets.QApplication.allWidgets()

widgets = dict((w.objectName(), w) for w in all_widgets)
menu = widgets.get(self._menu)

if menu:
Expand Down

0 comments on commit 8369285

Please sign in to comment.