From a040f4de82f4314a48f8e4629750fb00bef2c411 Mon Sep 17 00:00:00 2001 From: noirauds Date: Tue, 20 May 2014 21:53:12 +0200 Subject: [PATCH] Geography: Bug #007722 : segfault in cairo.SurfaceImage.create_from_png --- gramps/plugins/lib/maps/geography.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index 708e8ffae..6eb6f6ef4 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -152,10 +152,14 @@ class GeoGraphyView(OsmGps, NavigationView): self.geo_mainmap = None path = os.path.join(IMAGE_DIR, "48x48", ('gramps-geo-mainmap' + '.png' )) - self.geo_mainmap = cairo.ImageSurface.create_from_png(path) + with open(path, 'rb') as fh: # this is to avoid bug with cairo 1.8.8 + self.geo_mainmap = cairo.ImageSurface.create_from_png(fh) + #self.geo_mainmap = cairo.ImageSurface.create_from_png(path) path = os.path.join(IMAGE_DIR, "48x48", ('gramps-geo-altmap' + '.png' )) - self.geo_altmap = cairo.ImageSurface.create_from_png(path) + with open(path, 'rb') as fh: # this is to avoid bug with cairo 1.8.8 + self.geo_altmap = cairo.ImageSurface.create_from_png(fh) + #self.geo_altmap = cairo.ImageSurface.create_from_png(path) if ( config.get('geography.map_service') in ( constants.OPENSTREETMAP, constants.MAPS_FOR_FREE, @@ -171,7 +175,9 @@ class GeoGraphyView(OsmGps, NavigationView): EventType.MARRIAGE ): path = os.path.join(IMAGE_DIR, "48x48", (constants.ICONS.get(int(ident), default_image) + '.png' )) - self.geo_othermap[ident] = cairo.ImageSurface.create_from_png(path) + with open(path, 'rb') as fh: # this is to avoid bug with cairo 1.8.8 + self.geo_othermap[ident] = cairo.ImageSurface.create_from_png(fh) + #self.geo_othermap[ident] = cairo.ImageSurface.create_from_png(path) def add_bookmark(self, menu, handle): if handle: