File 0007-tiff-workaround-for-cairo-bug.patch of Package mingw32-evince

From c26274adbf87e51682714b019c39e5932c65931b Mon Sep 17 00:00:00 2001
From: Hib Eris <hib@hiberis.nl>
Date: Fri, 15 Jul 2011 13:57:38 +0200
Subject: [PATCH 07/12] tiff: workaround for cairo bug

When you call cairo_surface_destroy() on a surface that has snapshots,
your run _cairo_surface_detach_snapshots, which runs
_cairo_surface_detach_snapshot, which runs
_cairo_surface_snapshot_copy_on_write().
In _cairo_surface_snapshot_copy_on_write (), when
_cairo_image_surface_create_with_pixman_format () fails, e.g because
out of memory, surface->status is set to error, but this is not checked in
_cairo_surface_detach_snapshots().

To work around this, we do not call cairo_surface_destroy() but attach the surface to the cr, deferring destruction.
---
 backend/tiff/tiff-document.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/backend/tiff/tiff-document.c b/backend/tiff/tiff-document.c
index 7e3cfe7..304951e 100644
--- a/backend/tiff/tiff-document.c
+++ b/backend/tiff/tiff-document.c
@@ -631,7 +631,17 @@ tiff_document_print_print_page (EvDocumentPrint *document,
 	cairo_paint (cr);
 	cairo_restore (cr);
 
-	cairo_surface_destroy (surface);
+	// Hib Eris; 15/07/2011
+	// I think we should destroy 'surface' here, but it seems
+	// cairo does not handle this well:
+	// Destroying 'surface' will cause the detachment of snapshots by
+	// cairo. This will cause a _cairo_surface_snapshot_copy_on_write
+	// which can fail with an out-of-memory error for large images.
+	// The failure is not handled by cairo and not returned by
+	// cairo_surface_destroy.
+	// For now, we uncomment it and attach the surface to the cr, deferring destruction.
+	//cairo_surface_destroy (surface);
+	cairo_set_user_data (cr, &key, surface, (cairo_destroy_func_t)cairo_surface_destroy);
 }
 
 static void
-- 
1.7.5.4

openSUSE Build Service is sponsored by