[sapwood] restrict the scope of the GdkPixmap for the mask



commit fc4d959df81c7bd3e4abe727ff04de8680061ff0
Author: Sven Herzberg <herzi gnome-de org>
Date:   Fri Aug 13 12:26:44 2010 +0200

    restrict the scope of the GdkPixmap for the mask
    
    * engine/sapwood-pixmap.c: restrict the scope of that variable

 engine/sapwood-pixmap.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/engine/sapwood-pixmap.c b/engine/sapwood-pixmap.c
index c616727..2fab323 100644
--- a/engine/sapwood-pixmap.c
+++ b/engine/sapwood-pixmap.c
@@ -31,6 +31,8 @@
 #include <string.h>
 #include <unistd.h>
 
+static cairo_user_data_key_t  sapwood_pixmap_owner;
+
 gboolean sapwood_debug_scaling = FALSE;
 gboolean sapwood_debug_xtraps = FALSE;
 
@@ -474,7 +476,6 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
   cairo_surface_t* mask_surface = NULL;
   cairo_surface_t* tmp;
   gboolean         need_tmp_mask = FALSE;
-  GdkPixmap      * tmp_mask = NULL;
   cairo_t        * tmp_cr;
   cairo_t        * cr;
   gint             n;
@@ -514,13 +515,15 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
 
   if (need_tmp_mask)
     {
-      tmp_mask = gdk_pixmap_new (draw, tmp_width, tmp_height, 1);
-
+      GdkPixmap* tmp_mask = gdk_pixmap_new (draw, tmp_width, tmp_height, 1);
       cairo_t* mask_cr = gdk_cairo_create (tmp_mask);
+
       cairo_set_operator (mask_cr, CAIRO_OPERATOR_CLEAR);
       cairo_paint (mask_cr);
 
       mask_surface = cairo_surface_reference (cairo_get_target (mask_cr));
+      cairo_surface_set_user_data (mask_surface, &sapwood_pixmap_owner,
+                                   tmp_mask, (GFreeFunc) g_object_unref);
       cairo_destroy (mask_cr);
     }
 
@@ -578,8 +581,6 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
     {
       cairo_surface_destroy (mask_surface);
     }
-  if (tmp_mask)
-    g_object_unref (tmp_mask);
   cairo_destroy (tmp_cr);
   cairo_surface_destroy (tmp);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]