diff --git a/engine.py b/engine.py index 26dcbf2..dbb16ee 100644 --- a/engine.py +++ b/engine.py @@ -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 diff --git a/plugins/Shotgun/vrShotgun.py b/plugins/Shotgun/vrShotgun.py index e039b03..e65d7e7 100644 --- a/plugins/Shotgun/vrShotgun.py +++ b/plugins/Shotgun/vrShotgun.py @@ -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 @@ -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)