Skip to content

Commit

Permalink
[SHOT-3580] Fix VRED process hanging (#46)
Browse files Browse the repository at this point in the history
* Use the VRED plugin callback on before destroy, onDestroyVREDScriptPlugin, to envoke the VRED engine destroy method to ensure proper clean up on shutdown.
  • Loading branch information
staceyoue authored Oct 20, 2020
1 parent 4ef7282 commit fe49414
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
31 changes: 18 additions & 13 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,23 +295,28 @@ def show_panel(self, panel_id, title, bundle, widget_class, *args, **kwargs):
widget.show()
return widget

# As VRED doesn't have a method inside it's API to dock widget, we need to create one by hand,
# parent it to the main window and display the app widget inside
parent = self._get_dialog_parent()

dock_widget = QtGui.QDockWidget(title, parent=parent)
dock_widget.setObjectName(panel_id)

widget_instance = widget_class(*args, **kwargs)
widget_instance.setParent(dock_widget)
self._apply_external_styleshet(bundle, widget_instance)
if not self.has_ui:
self.log_error(
"Sorry, this environment does not support UI display! Cannot show "
"the requested window '{}'.".format(title)
)
return None

dock_widget.setWidget(widget_instance)
dock_widget.show()
# Create a dialog with the panel widget so that the TankQDialog class will take care of
# cleaning up the widget.
dialog, widget = self._create_dialog_with_widget(
title, bundle, widget_class, *args, **kwargs
)

# VRED does not have a Python PI method to dock a widget, so we need to create a dock widget
# and dock it to the VRED main window.
dock_widget = QtGui.QDockWidget(title)
dock_widget.setObjectName(panel_id)
dock_widget.setWidget(dialog)
parent = self._get_dialog_parent()
parent.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock_widget)

return widget_instance
return dock_widget

#####################################################################################
# VRED File IO
Expand Down
12 changes: 12 additions & 0 deletions plugins/Shotgun/vrShotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
logger = sgtk.LogManager.get_logger(__name__)
vrShotgun_form, vrShotgun_base = uiTools.loadUiType("vrShotgunGUI.ui")

# The vrShotgun plugin module instance
shotgun = None


class vrShotgun(vrShotgun_form, vrShotgun_base):
context = None
Expand Down Expand Up @@ -100,6 +103,15 @@ def resizeEvent(self, event):
return super(vrShotgun, self).resizeEvent(event)


def onDestroyVREDScriptPlugin():
"""
onDestroyVREDScriptPlugin() is called before this plugin is destroyed. In this
plugin we want to destroy the VRED engine, which will handle any necessary clean up.
"""
if shotgun and shotgun.engine:
shotgun.engine.destroy_engine()


try:
if os.getenv("SHOTGUN_ENABLE") == "1":
shotgun = vrShotgun(VREDPluginWidget)
Expand Down

0 comments on commit fe49414

Please sign in to comment.