Re: [patch] surface: set image->parent = NULL

"Henry (Yu) Song - SISA" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <3955FA337689574EB32F94B12A7E6E9E434ADAB8@sisaex01sj>
Please discard previous submitted patch, this patch is better.  Please review

From 3ec142e09018dc6a58f16c325fe77091e6d086c3 Mon Sep 17 00:00:00 2001
From: Henry Song <[email protected]>
Date: Wed, 30 Jan 2013 08:29:06 -0800
Subject: [PATCH 1/2] surface: increase reference count for parent of cloned
 image

If an image surface is created as result of
_cairo_image_surface_clone_subimage() during either
private call _cairo_surface_map_to_image() or
public call cairo_surface_map_to_image(),
we need to increase reference count of its parent to account for
parent's reference count descrease when image is destroyed
---
 src/cairo-surface.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index ffffef8..de16d86 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -639,6 +639,10 @@ _cairo_surface_map_to_image (cairo_surface_t  *surface,
     if (image == NULL)
 	image = _cairo_image_surface_clone_subimage (surface, extents);
 
+    /* add a reference count to parent if it exists */
+    if (image->parent)
+	cairo_surface_reference (image->parent);
+
     return image;
 }
 
@@ -791,6 +795,10 @@ cairo_surface_map_to_image (cairo_surface_t  *surface,
     if (image->format == CAIRO_FORMAT_INVALID) {
 	cairo_surface_destroy (&image->base);
 	image = _cairo_image_surface_clone_subimage (surface, extents);
+	
+	/* if parent exists, add reference count */
+	if (image->parent)
+	    cairo_surface_reference (image->parent);
     }
 
     return &image->base;
-- 
1.7.9.5





________________________________________
From: [email protected] [[email protected]] on behalf of Henry (Yu) Song - SISA [[email protected]]
Sent: Wednesday, January 30, 2013 8:31 AM
To: [email protected]
Subject: [cairo] [patch] surface: set image->parent = NULL

From 5d9a4aeaccc6497105ae4ad1347bc08165cff92f Mon Sep 17 00:00:00 2001
From: Henry Song <[email protected]>
Date: Wed, 30 Jan 2013 08:29:06 -0800
Subject: [PATCH] surface: for image->parent = NULL in
 cairo_surface_map_to_image()

This ensures parent's reference count will get decreased during
cairo_surface_unmap_image()
---
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.