Bug 7258: Work around bug in Py2Cairo 1.8.10 and earlier on Linux

(cherry picked from commit 117fbe2810)
This commit is contained in:
John Ralls 2014-04-15 11:46:16 -07:00
parent f6be31eb39
commit 081675c4bc
2 changed files with 14 additions and 6 deletions

View File

@ -28,8 +28,6 @@
# Python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import sys
#------------------------------------------------------------------------
@ -40,7 +38,9 @@ import sys
import gramps.plugins.lib.libcairodoc as libcairodoc
from gramps.gen.plug.docgen import INDEX_TYPE_ALP, INDEX_TYPE_TOC
from gramps.gen.errors import ReportError
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.constfunc import lin
#------------------------------------------------------------------------
#
# Set up logging
@ -94,6 +94,10 @@ class CairoDocgen(libcairodoc.CairoDoc):
# create cairo context and pango layout
filename = self._backend.filename
# Work around a bug in pycairo 1.8.10 and earlier. OSX and
# Win32 AIOs use pycairo 1.10.0, in which the bug is fixed.
if (sys.version_info[0] < 3 and lin()):
filename = filename.encode(glocale.getfilesystemencoding())
try:
surface = self.create_cairo_surface(filename, paper_width, paper_height)
except IOError as msg:

View File

@ -29,8 +29,6 @@
#-------------------------------------------------------------------------
from __future__ import unicode_literals, division
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from cgi import escape
import math
import sys
@ -75,7 +73,9 @@ from gramps.gen.const import CUSTOM_FILTERS
from gramps.gen.constfunc import is_quartz, win
from gramps.gui.dialog import RunDatabaseRepair, ErrorDialog
from gramps.gui.utils import color_graph_box, hex_to_rgb_float, is_right_click
from gramps.gen.constfunc import STRTYPE
from gramps.gen.constfunc import STRTYPE, lin
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#-------------------------------------------------------------------------
#
@ -207,6 +207,10 @@ class PersonBoxWidgetCairo(_PersonWidgetBase):
if image:
image_path = self.get_image(dbstate, person)
if image_path and os.path.exists(image_path):
# Work around a bug in pycairo 1.8.10 and earlier. OSX and
# Win32 AIOs use pycairo 1.10.0, in which the bug is fixed.
if (sys.version_info[0] < 3 and lin()):
image_path = image_path.encode(glocale.getfilesystemencoding())
self.img_surf = cairo.ImageSurface.create_from_png(image_path)
# enable mouse-over