[gimp/goat-invasion: 4/526] imagemap: unref buffers as soon as possible



commit dff4667ecd37cf066f4f940bef07e4ab9f54a773
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Tue Mar 13 17:12:45 2012 +0000

    imagemap: unref buffers as soon as possible

 app/core/gimpimagemap.c |   40 ++++++++++------------------------------
 1 files changed, 10 insertions(+), 30 deletions(-)
---
diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c
index 1783117..d890b8c 100644
--- a/app/core/gimpimagemap.c
+++ b/app/core/gimpimagemap.c
@@ -81,12 +81,10 @@ struct _GimpImageMap
   PixelRegionIterator   *PRI;
 
   GeglNode              *gegl;
-  GeglBuffer            *input_buffer;
   GeglNode              *input;
   GeglNode              *translate;
   GeglNode              *operation;
   GeglNode              *output;
-  GeglBuffer            *output_buffer;
   GeglProcessor         *processor;
 
   guint                  idle_id;
@@ -181,9 +179,6 @@ gimp_image_map_init (GimpImageMap *image_map)
 
   image_map->pixel_count   = 0;
 
-  image_map->input_buffer = NULL;
-  image_map->output_buffer = NULL;
-
   if (image_map->timer)
     g_timer_stop (image_map->timer);
 }
@@ -204,17 +199,6 @@ gimp_image_map_finalize (GObject *object)
 {
   GimpImageMap *image_map = GIMP_IMAGE_MAP (object);
 
-  if (image_map->input_buffer)
-    {
-      g_object_unref (image_map->input_buffer);
-      image_map->input_buffer = NULL;
-    }
-  if (image_map->output_buffer)
-    {
-      g_object_unref (image_map->output_buffer);
-      image_map->output_buffer = NULL;
-    }
-
   if (image_map->undo_desc)
     {
       g_free (image_map->undo_desc);
@@ -394,20 +378,13 @@ gimp_image_map_apply (GimpImageMap        *image_map,
 
   if (image_map->operation)
     {
-      if (image_map->input_buffer)
-        {
-          g_object_unref (image_map->input_buffer);
-          image_map->input_buffer = NULL;
-        }
-      if (image_map->output_buffer)
-        {
-          g_object_unref (image_map->output_buffer);
-          image_map->output_buffer = NULL;
-        }
+      GeglBuffer *input_buffer;
+      GeglBuffer *output_buffer;
 
-      image_map->input_buffer =
+      input_buffer =
         gimp_tile_manager_get_gegl_buffer (image_map->undo_tiles, FALSE);
-      image_map->output_buffer = gimp_tile_manager_get_gegl_buffer (gimp_drawable_get_shadow_tiles (image_map->drawable), TRUE);
+      output_buffer =
+        gimp_tile_manager_get_gegl_buffer (gimp_drawable_get_shadow_tiles (image_map->drawable), TRUE);
 
       if (! image_map->gegl)
         {
@@ -481,7 +458,7 @@ gimp_image_map_apply (GimpImageMap        *image_map,
         }
 
       gegl_node_set (image_map->input,
-                     "buffer", image_map->input_buffer,
+                     "buffer", input_buffer,
                      NULL);
 
       gegl_node_set (image_map->translate,
@@ -490,11 +467,14 @@ gimp_image_map_apply (GimpImageMap        *image_map,
                      NULL);
 
       gegl_node_set (image_map->output,
-                     "buffer", image_map->output_buffer,
+                     "buffer", output_buffer,
                      NULL);
 
       image_map->processor = gegl_node_new_processor (image_map->output,
                                                       &rect);
+
+      g_object_unref (input_buffer);
+      g_object_unref (output_buffer);
     }
   else
     {



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