Skip to content

Commit

Permalink
Fix #120
Browse files Browse the repository at this point in the history
Thanks @BigRoy!
  • Loading branch information
mottosso committed Mar 2, 2017
1 parent 60b7bad commit 6710367
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions pyblish_qml/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,24 @@ def install_host():
break


def _on_application_quit():
"""Automatically kill QML on host exit"""

try:
_state["currentServer"].popen.kill()

except KeyError:
# No server started
pass

except OSError:
# Already dead
pass


def _install_maya():
"""Helper function to Autodesk Maya support"""
from maya import cmds, utils
from maya import utils

def threaded_wrapper(func, *args, **kwargs):
return utils.executeInMainThreadWithResult(
Expand All @@ -208,22 +223,8 @@ def threaded_wrapper(func, *args, **kwargs):
sys.stdout.write("Setting up Pyblish QML in Maya\n")
register_dispatch_wrapper(threaded_wrapper)

def on_application_quit():
try:
_state["currentServer"].popen.kill()

except KeyError:
# No server started
pass

except OSError:
# Already dead
pass

cmds.scriptJob(
event=["quitApplication", on_application_quit],
protected=True
)
app = QtWidgets.QApplication.instance()
app.aboutToQuit.connect(_on_application_quit)

# Configure GUI
settings.ContextLabel = "Maya"
Expand All @@ -241,6 +242,9 @@ def threaded_wrapper(func, *args, **kwargs):
sys.stdout.write("Setting up Pyblish QML in Houdini\n")
register_dispatch_wrapper(threaded_wrapper)

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

settings.ContextLabel = "Houdini"
settings.WindowTitle = "Pyblish (Houdini)"

Expand All @@ -259,6 +263,9 @@ def threaded_wrapper(func, *args, **kwargs):
sys.stdout.write("Setting up Pyblish QML in Nuke\n")
register_dispatch_wrapper(threaded_wrapper)

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

settings.ContextLabel = "Nuke"
settings.WindowTitle = "Pyblish (Nuke)"

Expand All @@ -278,6 +285,9 @@ def threaded_wrapper(func, *args, **kwargs):
sys.stdout.write("Setting up Pyblish QML in Hiero\n")
register_dispatch_wrapper(threaded_wrapper)

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

settings.ContextLabel = "Hiero"
settings.WindowTitle = "Pyblish (Hiero)"

Expand Down

0 comments on commit 6710367

Please sign in to comment.