Skip to content

Commit

Permalink
Refs #11016 Throw error on invalid screenshot
Browse files Browse the repository at this point in the history
Throw a meaningful error, and allow it to propagate up the call chain.
  • Loading branch information
Harry Jeffery committed Feb 9, 2015
1 parent 85a4f43 commit c6af857
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 1 addition & 8 deletions Code/Mantid/docs/sphinxext/mantiddoc/directives/interface.py
Expand Up @@ -59,14 +59,7 @@ def _create_screenshot(self, widget_name = None):
if not os.path.exists(screenshots_dir):
os.makedirs(screenshots_dir)

try:
picture = custominterface_screenshot(self.interface_name(), screenshots_dir, widget_name = widget_name)
except RuntimeError, exc:
env = self.state.document.settings.env
env.warn(env.docname, "Unable to generate screenshot for '%s' - %s" % (self.interface_name(), str(exc)))
picture = None

return picture
return custominterface_screenshot(self.interface_name(), screenshots_dir, widget_name = widget_name)

def _insert_screenshot_link(self, picture, align=None, width=None):
"""
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/docs/sphinxext/mantiddoc/tools/screenshot.py
Expand Up @@ -85,8 +85,13 @@ def custominterface_screenshot(name, directory, ext = ".png", widget_name = None
# threadsafe_call required for MantidPlot
dlg = threadsafe_call(iface_mgr.createSubWindow, name, None)

if dlg is None:
raise RuntimeError("Interface '%s' could not be created" % name)

if widget_name:
widget = dlg.findChild(QWidget, widget_name)
if widget is None:
raise RuntimeError("Widget '%s' does not exist in interface '%s'" % (widget_name, name))
picture = Screenshot(widget, name.replace(' ','_') + "_" + widget_name + "_widget" + ext, directory)
else:
picture = Screenshot(dlg, name.replace(' ','_') + "_interface" + ext, directory)
Expand Down

0 comments on commit c6af857

Please sign in to comment.