[gimp] Make gimp_buffer_new() ref the passed tiles



commit de583d4c28b00f7c31def31b174a02213500bd6d
Author: Michael Natterer <mitch gimp org>
Date:   Fri Mar 19 09:52:29 2010 +0100

    Make gimp_buffer_new() ref the passed tiles
    
    and clean up gimp-edit.c a bit as a result.

 app/core/gimp-edit.c  |   18 +++++++++---------
 app/core/gimpbuffer.c |    9 +++++++--
 2 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 0016d94..6d451ec 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -57,8 +57,6 @@ static GimpBuffer * gimp_edit_extract         (GimpImage            *image,
                                                GimpContext          *context,
                                                gboolean              cut_pixels,
                                                GError              **error);
-static GimpBuffer * gimp_edit_make_buffer     (Gimp                 *gimp,
-                                               TileManager          *tiles);
 static gboolean     gimp_edit_fill_internal   (GimpImage            *image,
                                                GimpDrawable         *drawable,
                                                GimpContext          *context,
@@ -509,14 +507,16 @@ gimp_edit_extract (GimpImage     *image,
   if (cut_pixels)
     gimp_image_undo_group_end (image);
 
-  return gimp_edit_make_buffer (image->gimp, tiles);
-}
+  if (tiles)
+    {
+      GimpBuffer *buffer = gimp_buffer_new (tiles, _("Global Buffer"), FALSE);
 
-static GimpBuffer *
-gimp_edit_make_buffer (Gimp        *gimp,
-                       TileManager *tiles)
-{
-  return tiles ? gimp_buffer_new (tiles, _("Global Buffer"), FALSE) : NULL;
+      tile_manager_unref (tiles);
+
+      return buffer;
+    }
+
+  return NULL;
 }
 
 static gboolean
diff --git a/app/core/gimpbuffer.c b/app/core/gimpbuffer.c
index bec8f68..fea787d 100644
--- a/app/core/gimpbuffer.c
+++ b/app/core/gimpbuffer.c
@@ -246,7 +246,7 @@ gimp_buffer_new (TileManager *tiles,
     }
   else
     {
-      buffer->tiles = tiles;
+      buffer->tiles = tile_manager_ref (tiles);
     }
 
   return buffer;
@@ -256,6 +256,7 @@ GimpBuffer *
 gimp_buffer_new_from_pixbuf (GdkPixbuf   *pixbuf,
                              const gchar *name)
 {
+  GimpBuffer  *buffer;
   TileManager *tiles;
   guchar      *pixels;
   PixelRegion  destPR;
@@ -284,7 +285,11 @@ gimp_buffer_new_from_pixbuf (GdkPixbuf   *pixbuf,
       pixel_region_set_row (&destPR, 0, y, width, pixels);
    }
 
-  return gimp_buffer_new (tiles, name, FALSE);
+  buffer = gimp_buffer_new (tiles, name, FALSE);
+
+  tile_manager_unref (tiles);
+
+  return buffer;
 }
 
 gint



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