Permalink
Browse files

Spot when a GUI is not available, e.g. when run via mayapy

  • Loading branch information...
mottosso committed Jan 18, 2018
1 parent 1a35024 commit 80a515672e2497e887804fa136fa5cb07e95546e
Showing with 23 additions and 13 deletions.
  1. +23 −13 pyblish_qml/host.py
@@ -95,21 +95,28 @@ def show(parent=None, targets=[], modal=None):
# The running instance has already been closed.
_state.pop("currentServer")

splash = Splash()
splash.show()
app = QtWidgets.QApplication.instance()

def on_shown():
try:
splash.close()
if isinstance(app, QtWidgets.QApplication):
# mayapy would have a QtGui.QGuiApplication
splash = Splash()
splash.show()

except RuntimeError:
# Splash already closed
pass
def on_shown():
try:
splash.close()

except RuntimeError:
# Splash already closed
pass

pyblish.api.deregister_callback(*callback)
pyblish.api.deregister_callback(*callback)

callback = "pyblishQmlShown", on_shown
pyblish.api.register_callback(*callback)
callback = "pyblishQmlShown", on_shown
pyblish.api.register_callback(*callback)
else:
def on_shown():
pass

try:
service = ipc.service.Service()
@@ -343,8 +350,11 @@ def threaded_wrapper(func, *args, **kwargs):
register_dispatch_wrapper(threaded_wrapper)

app = QtWidgets.QApplication.instance()
app.aboutToQuit.connect(_on_application_quit)
_connect_host_event(app)

if isinstance(app, QtWidgets.QApplication):
# mayapy would have a QtGui.QGuiApplication
app.aboutToQuit.connect(_on_application_quit)
_connect_host_event(app)

if settings.ContextLabel == settings.ContextLabelDefault:
settings.ContextLabel = "Maya"

0 comments on commit 80a5156

Please sign in to comment.