Skip to content

Commit

Permalink
Make pre-rendering slightly more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
Cimbali committed Dec 1, 2017
1 parent af8acfe commit 9193ef3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pympress/surfacecache.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def renderer(self, widget_name, page_nb):
- check if the job's result is not already available in the cache
- render it in a new :class:`~cairo.ImageSurface` if necessary
- store it in the cache if it was not added there since the beginning of
the process
the process and the widget configuration is still valid
Args:
widget_name (`str`): name of the concerned widget
Expand All @@ -283,9 +283,12 @@ def renderer(self, widget_name, page_nb):
pw, ph = page.get_size(wtype)

# Render to a ImageSurface
# 32 to support alpha (needed with premultiplied values?)
# Anyway 24 uses 32-bit values with 8 unused
surface = self.surface_factory[widget_name](cairo.CONTENT_COLOR, ww, wh)
try:
surface = self.surface_factory[widget_name](cairo.CONTENT_COLOR, ww, wh)
except AttributeError:
logger.warning('Widget {} was not mapped when rendering'.format(widget_name), exc_info = True)
return False

context = cairo.Context(surface)
page.render_cairo(context, ww, wh, wtype)
del context
Expand Down

0 comments on commit 9193ef3

Please sign in to comment.