? Gen-Patch.bash
? gimptool-2.1
? my-commit.txt
? patch1.txt
? app/cmds.gdb
? app/diff.txt
? app/gimp-2.1
? app/pattern-search-results.txt
? app/search-results.txt
? app/core/gp.diff
? app/core/search-results.txt
? app/file/file-save.c.new
? app/paint-funcs/paint-funcs-generic-annotated.h
? app/paint-funcs/paint-funcs-generic.h.new
? app/paint-funcs/paint-funcs.c.new
? data/images/log.txt
? data/misc/Makefile
? data/misc/Makefile.in
? data/misc/gimp.applications
? data/misc/gimp.desktop
? data/misc/gimp.desktop.in
? data/misc/gimp.keys
? docs/gimp-2.1.1
? docs/gimp-remote-2.1.1
? docs/gimprc-2.1.5
? docs/gimptool-2.1.1
? plug-ins/common/bz2
? plug-ins/common/dindinx-sparkle.patch
? plug-ins/common/gz
? plug-ins/common/hrz
? plug-ins/common/jpeg
? plug-ins/common/plugindetails
? plug-ins/common/sparkle.before.c
? plug-ins/common/url
? plug-ins/dbbrowser/Makefile
? plug-ins/dbbrowser/Makefile.in
? plug-ins/dbbrowser/dbbrowser
? plug-ins/dbbrowser/plugin-browser
? plug-ins/dbbrowser/procedure-browser
? plug-ins/fp/Makefile
? plug-ins/fp/Makefile.in
? plug-ins/fp/fp
? plug-ins/gimpressionist/logo-pixbuf.h
? plug-ins/libgimpoldpreview/Makefile
? plug-ins/libgimpoldpreview/Makefile.in
? tips/Makefile
? tips/Makefile.in
? tips/gimp-tips.xml
? tips/gimp20-tips.pot
? tools/gimp-remote-2.1
? tools/authorsgen/Makefile
? tools/authorsgen/Makefile.in
? tools/authorsgen/stamp-authors
? tools/pdbgen/stamp-enum-code-py
? tools/pdbgen/pdb/diff.txt
Index: app/core/gimpbrush-load.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpbrush-load.c,v
retrieving revision 1.95
diff -u -3 -p -r1.95 gimpbrush-load.c
--- app/core/gimpbrush-load.c	8 Jun 2005 11:27:31 -0000	1.95
+++ app/core/gimpbrush-load.c	7 Feb 2006 11:01:25 -0000
@@ -136,10 +136,6 @@ gimp_brush_load_brush (gint          fd,
   gint         bn_size;
   BrushHeader  header;
   gchar       *name = NULL;
-  guchar      *pixmap;
-  guchar      *mask;
-  gssize       i, size;
-  gboolean     success = TRUE;
 
   g_return_val_if_fail (filename != NULL, NULL);
   g_return_val_if_fail (fd != -1, NULL);
@@ -263,12 +259,56 @@ gimp_brush_load_brush (gint          fd,
                         NULL);
   g_free (name);
 
-  brush->mask = temp_buf_new (header.width, header.height, 1, 0, 0, NULL);
+  brush->spacing  = header.spacing;
+  brush->x_axis.x = header.width  / 2.0;
+  brush->x_axis.y = 0.0;
+  brush->y_axis.x = 0.0;
+  brush->y_axis.y = header.height / 2.0;
+  
+  brush->width       = header.width;
+  brush->height      = header.height;
+  brush->bytes       = header.bytes;
+  brush->brush_type  = GIMP_BRUSH_TYPE_REGULAR;
+  brush->data_offset = lseek(fd, 0, SEEK_CUR);
+
+  /* Skip the data - some calls to gimp_brush_load_brush() expect
+   * us to read the entire brush data, as a brush will follow next.
+   * */
+  lseek (fd, header.width*header.height*header.bytes, SEEK_CUR);
+
+  return brush;
+}
+
+gboolean
+gimp_brush_data_load (GimpData         *data,
+                      GError          **error)
+{
+  GimpBrush   *brush;
+  guchar      *mask;
+  gssize       i, size;
+  gint         fd;
+  gboolean     success = TRUE;
+  guchar      *pixmap;
+  
+  brush = GIMP_BRUSH (data);
+
+  fd = g_open (data->filename, O_RDONLY | _O_BINARY, 0);
+  if (fd == -1)
+    {
+      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
+                   _("Could not open '%s' for reading: %s"),
+                   gimp_filename_to_utf8 (data->filename), g_strerror (errno));
+      return FALSE;
+    }
+
+  lseek (fd, brush->data_offset, SEEK_SET);
+
+  brush->mask = temp_buf_new (brush->width, brush->height, 1, 0, 0, NULL);
 
   mask = temp_buf_data (brush->mask);
-  size = header.width * header.height * header.bytes;
+  size = brush->width * brush->height * brush->bytes;
 
-  switch (header.bytes)
+  switch (brush->bytes)
     {
     case 1:
       success = (read (fd, mask, size) == size);
@@ -317,7 +357,7 @@ gimp_brush_load_brush (gint          fd,
       {
         guchar buf[8 * 1024];
 
-        brush->pixmap = temp_buf_new (header.width, header.height,
+        brush->pixmap = temp_buf_new (brush->width, brush->height,
                                       3, 0, 0, NULL);
         pixmap = temp_buf_data (brush->pixmap);
 
@@ -352,8 +392,8 @@ gimp_brush_load_brush (gint          fd,
                    _("Fatal parse error in brush file '%s': "
                      "Unsupported brush depth %d\n"
                      "GIMP brushes must be GRAY or RGBA."),
-                   gimp_filename_to_utf8 (filename), header.bytes);
-      return NULL;
+                   gimp_filename_to_utf8 (data->filename), brush->bytes);
+      return FALSE;
     }
 
   if (! success)
@@ -362,17 +402,11 @@ gimp_brush_load_brush (gint          fd,
       g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
                    _("Fatal parse error in brush file '%s': "
                      "File appears truncated."),
-                   gimp_filename_to_utf8 (filename));
-      return NULL;
+                   gimp_filename_to_utf8 (data->filename));
+      return FALSE;
     }
-
-  brush->spacing  = header.spacing;
-  brush->x_axis.x = header.width  / 2.0;
-  brush->x_axis.y = 0.0;
-  brush->y_axis.x = 0.0;
-  brush->y_axis.y = header.height / 2.0;
-
-  return brush;
+  close(fd);
+  return TRUE;
 }
 
 GList *
Index: app/core/gimpbrush.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpbrush.c,v
retrieving revision 1.97
diff -u -3 -p -r1.97 gimpbrush.c
--- app/core/gimpbrush.c	10 Dec 2005 19:24:34 -0000	1.97
+++ app/core/gimpbrush.c	7 Feb 2006 11:01:25 -0000
@@ -64,6 +64,7 @@ static gboolean    gimp_brush_real_want_
                                                      GimpCoords    *last_coords,
                                                      GimpCoords    *cur_coords);
 
+static void gimp_brush_data_unload (GimpData *);
 
 G_DEFINE_TYPE (GimpBrush, gimp_brush, GIMP_TYPE_DATA);
 
@@ -99,6 +100,8 @@ gimp_brush_class_init (GimpBrushClass *k
   viewable_class->get_description  = gimp_brush_get_description;
 
   data_class->get_extension        = gimp_brush_get_extension;
+  data_class->load                 = gimp_brush_data_load;
+  data_class->unload               = gimp_brush_data_unload;
 
   klass->select_brush              = gimp_brush_real_select_brush;
   klass->want_null_motion          = gimp_brush_real_want_null_motion;
@@ -116,6 +119,7 @@ gimp_brush_init (GimpBrush *brush)
   brush->x_axis.y =  0.0;
   brush->y_axis.x =  0.0;
   brush->y_axis.y = 15.0;
+  brush->brush_type = GIMP_BRUSH_TYPE_UNKNOWN;
 }
 
 static void
@@ -162,8 +166,8 @@ gimp_brush_get_size (GimpViewable *viewa
 {
   GimpBrush *brush = GIMP_BRUSH (viewable);
 
-  *width  = brush->mask->width;
-  *height = brush->mask->height;
+  *width  = brush->width;
+  *height = brush->height;
 
   return TRUE;
 }
@@ -184,6 +188,13 @@ gimp_brush_get_new_preview (GimpViewable
   guchar    *buf;
   gint       x, y;
   gboolean   scale = FALSE;
+  GError    *error = NULL;
+
+  if (!gimp_data_load (GIMP_DATA (brush), &error))
+    {
+      g_clear_error (&error);
+      return NULL;
+    }
 
   mask_buf   = gimp_brush_get_mask (brush);
   pixmap_buf = gimp_brush_get_pixmap (brush);
@@ -258,6 +269,8 @@ gimp_brush_get_new_preview (GimpViewable
         temp_buf_free (pixmap_buf);
     }
 
+  gimp_data_unload (GIMP_DATA (brush));
+
   return return_buf;
 }
 
@@ -269,8 +282,8 @@ gimp_brush_get_description (GimpViewable
 
   return g_strdup_printf ("%s (%d x %d)",
                           GIMP_OBJECT (brush)->name,
-                          brush->mask->width,
-                          brush->mask->height);
+                          brush->width,
+                          brush->height);
 }
 
 static gchar *
@@ -399,3 +412,31 @@ gimp_brush_spacing_changed (GimpBrush *b
 
   g_signal_emit (brush, brush_signals[SPACING_CHANGED], 0);
 }
+
+static void
+gimp_brush_data_unload (GimpData *data)
+{
+  GimpBrush *brush = GIMP_BRUSH (data);
+
+  /*
+   * TODO : Temporary - until we work out the abr brushes too.
+   * */
+  if (brush->brush_type == GIMP_BRUSH_TYPE_UNKNOWN)
+    {
+      return;
+    }
+  /* END TODO */
+
+  if (brush->mask)
+    {
+      temp_buf_free (brush->mask);
+      brush->mask = NULL;
+    }
+
+  if (brush->pixmap)
+    {
+      temp_buf_free (brush->pixmap);
+      brush->pixmap = NULL;
+    }
+}
+
Index: app/core/gimpbrush.h
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpbrush.h,v
retrieving revision 1.37
diff -u -3 -p -r1.37 gimpbrush.h
--- app/core/gimpbrush.h	8 Jun 2005 11:27:31 -0000	1.37
+++ app/core/gimpbrush.h	7 Feb 2006 11:01:25 -0000
@@ -33,6 +33,12 @@
 
 typedef struct _GimpBrushClass GimpBrushClass;
 
+enum GIMP_BRUSH_TYPE
+{
+  GIMP_BRUSH_TYPE_UNKNOWN = 0,
+  GIMP_BRUSH_TYPE_REGULAR,
+};
+
 struct _GimpBrush
 {
   GimpData      parent_instance;
@@ -43,6 +49,12 @@ struct _GimpBrush
   gint          spacing;    /*  brush's spacing                */
   GimpVector2   x_axis;     /*  for calculating brush spacing  */
   GimpVector2   y_axis;     /*  for calculating brush spacing  */
+
+  guint32       width;
+  guint32       height;
+  guint32       bytes;
+  guint32       data_offset;  
+  gint          brush_type;
 };
 
 struct _GimpBrushClass
@@ -81,6 +93,7 @@ gint        gimp_brush_get_spacing      
 void        gimp_brush_set_spacing      (GimpBrush        *brush,
                                          gint              spacing);
 void        gimp_brush_spacing_changed  (GimpBrush        *brush);
-
+gboolean    gimp_brush_data_load        (GimpData *,
+                                         GError          **error);
 
 #endif /* __GIMP_BRUSH_H__ */
Index: app/core/gimpbrushgenerated.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpbrushgenerated.c,v
retrieving revision 1.77
diff -u -3 -p -r1.77 gimpbrushgenerated.c
--- app/core/gimpbrushgenerated.c	10 Dec 2005 19:24:34 -0000	1.77
+++ app/core/gimpbrushgenerated.c	7 Feb 2006 11:01:25 -0000
@@ -93,6 +93,8 @@ gimp_brush_generated_class_init (GimpBru
   data_class->dirty          = gimp_brush_generated_dirty;
   data_class->get_extension  = gimp_brush_generated_get_extension;
   data_class->duplicate      = gimp_brush_generated_duplicate;
+  data_class->load           = NULL;
+  data_class->unload         = NULL;
 
   g_object_class_install_property (object_class, PROP_SHAPE,
                                    g_param_spec_enum ("shape", NULL, NULL,
Index: app/core/gimpbrushpipe.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpbrushpipe.c,v
retrieving revision 1.86
diff -u -3 -p -r1.86 gimpbrushpipe.c
--- app/core/gimpbrushpipe.c	10 Dec 2005 19:24:34 -0000	1.86
+++ app/core/gimpbrushpipe.c	7 Feb 2006 11:01:25 -0000
@@ -73,7 +73,9 @@ static GimpBrush * gimp_brush_pipe_selec
 static gboolean    gimp_brush_pipe_want_null_motion (GimpBrush    *brush,
                                                      GimpCoords   *last_coords,
                                                      GimpCoords   *cur_coords);
-
+static gboolean    gimp_brush_pipe_data_load        (GimpData *data,
+                                                     GError  **error);
+static void        gimp_brush_pipe_data_unload      (GimpData *data);
 
 G_DEFINE_TYPE (GimpBrushPipe, gimp_brush_pipe, GIMP_TYPE_BRUSH);
 
@@ -86,6 +88,7 @@ gimp_brush_pipe_class_init (GimpBrushPip
   GObjectClass      *object_class      = G_OBJECT_CLASS (klass);
   GimpObjectClass   *gimp_object_class = GIMP_OBJECT_CLASS (klass);
   GimpViewableClass *viewable_class    = GIMP_VIEWABLE_CLASS (klass);
+  GimpDataClass     *data_class        = GIMP_DATA_CLASS (klass);
   GimpBrushClass    *brush_class       = GIMP_BRUSH_CLASS (klass);
 
   object_class->finalize         = gimp_brush_pipe_finalize;
@@ -94,6 +97,9 @@ gimp_brush_pipe_class_init (GimpBrushPip
 
   viewable_class->get_popup_size = gimp_brush_pipe_get_popup_size;
 
+  data_class->load               = gimp_brush_pipe_data_load;
+  data_class->unload             = gimp_brush_pipe_data_unload;
+
   brush_class->select_brush      = gimp_brush_pipe_select_brush;
   brush_class->want_null_motion  = gimp_brush_pipe_want_null_motion;
 }
@@ -433,8 +439,11 @@ gimp_brush_pipe_load (const gchar  *file
 
       if (pipe->brushes[pipe->nbrushes])
 	{
-	  gimp_object_set_name (GIMP_OBJECT (pipe->brushes[pipe->nbrushes]),
-				NULL);
+	  gimp_object_set_name   (GIMP_OBJECT (pipe->brushes[pipe->nbrushes]),
+				  NULL);
+          gimp_data_set_filename (GIMP_DATA (pipe->brushes[pipe->nbrushes]),
+                                  filename,
+                                  FALSE, FALSE);
 	}
       else
 	{
@@ -459,8 +468,43 @@ gimp_brush_pipe_load (const gchar  *file
   GIMP_BRUSH (pipe)->spacing  = pipe->current->spacing;
   GIMP_BRUSH (pipe)->x_axis   = pipe->current->x_axis;
   GIMP_BRUSH (pipe)->y_axis   = pipe->current->y_axis;
+
+  return g_list_prepend (NULL, pipe);
+}
+
+static gboolean
+gimp_brush_pipe_data_load (GimpData *data,
+                           GError  **error)
+{
+  GimpBrushPipe *pipe = GIMP_BRUSH_PIPE (data);
+  int i;
+
+  for (i = 0; i < pipe->nbrushes; i++)
+    {
+      if (!gimp_data_load (GIMP_DATA (pipe->brushes[i]), error))
+        {
+          return FALSE;
+        }
+    }
+  /*  just to satisfy the code that relies on this crap  */
   GIMP_BRUSH (pipe)->mask     = pipe->current->mask;
   GIMP_BRUSH (pipe)->pixmap   = pipe->current->pixmap;
+  
+  return TRUE;
+}
 
-  return g_list_prepend (NULL, pipe);
+static void
+gimp_brush_pipe_data_unload (GimpData *data)
+{
+  GimpBrushPipe *pipe = GIMP_BRUSH_PIPE (data);
+  int i;
+
+  for ( i = 0; i < pipe->nbrushes; i++)
+    {
+      gimp_data_unload (GIMP_DATA (pipe->brushes[i]));
+    }
+  /*  just to satisfy the code that relies on this crap  */
+  GIMP_BRUSH (pipe)->mask     = NULL;
+  GIMP_BRUSH (pipe)->pixmap   = NULL;
 }
+
Index: app/core/gimpcontext.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpcontext.c,v
retrieving revision 1.124
diff -u -3 -p -r1.124 gimpcontext.c
--- app/core/gimpcontext.c	27 Dec 2005 18:56:25 -0000	1.124
+++ app/core/gimpcontext.c	7 Feb 2006 11:01:30 -0000
@@ -2408,6 +2408,7 @@ gimp_context_real_set_brush (GimpContext
       g_signal_handlers_disconnect_by_func (context->brush,
                                             gimp_context_brush_dirty,
                                             context);
+      gimp_data_unload (GIMP_DATA (context->brush));
       g_object_unref (context->brush);
     }
 
@@ -2415,8 +2416,15 @@ gimp_context_real_set_brush (GimpContext
 
   if (brush)
     {
+      GError *error = NULL;
       g_object_ref (brush);
 
+      if (!gimp_data_load (GIMP_DATA (brush), &error))
+        {
+          fprintf (stderr, "%s\n", error->message);
+          g_error_free (error);
+        }
+
       g_signal_connect_object (brush, "name-changed",
                                G_CALLBACK (gimp_context_brush_dirty),
                                context,
@@ -2530,15 +2538,23 @@ gimp_context_real_set_pattern (GimpConte
       g_signal_handlers_disconnect_by_func (context->pattern,
                                             gimp_context_pattern_dirty,
                                             context);
-      g_object_unref (context->pattern);
+      gimp_data_unload (GIMP_DATA (context->pattern));
+      g_object_unref   (context->pattern);
     }
 
   context->pattern = pattern;
 
   if (pattern)
     {
+      GError *error = NULL;
       g_object_ref (pattern);
 
+      if (!gimp_data_load (GIMP_DATA (pattern), &error))
+        {
+          fprintf (stderr, "%s\n", error->message);
+          g_error_free (error);
+        }
+
       g_signal_connect_object (pattern, "name-changed",
                                G_CALLBACK (gimp_context_pattern_dirty),
                                context,
@@ -2652,6 +2668,7 @@ gimp_context_real_set_gradient (GimpCont
       g_signal_handlers_disconnect_by_func (context->gradient,
                                             gimp_context_gradient_dirty,
                                             context);
+      gimp_data_unload (GIMP_DATA (context->gradient));
       g_object_unref (context->gradient);
     }
 
@@ -2659,8 +2676,15 @@ gimp_context_real_set_gradient (GimpCont
 
   if (gradient)
     {
+      GError *error = NULL;
       g_object_ref (gradient);
 
+      if (!gimp_data_load (GIMP_DATA (gradient), &error))
+        {
+          fprintf (stderr, "%s\n", error->message);
+          g_error_free (error);
+        }
+
       g_signal_connect_object (gradient, "name-changed",
                                G_CALLBACK (gimp_context_gradient_dirty),
                                context,
@@ -2774,6 +2798,7 @@ gimp_context_real_set_palette (GimpConte
       g_signal_handlers_disconnect_by_func (context->palette,
                                             gimp_context_palette_dirty,
                                             context);
+      gimp_data_unload (GIMP_DATA (context->palette));
       g_object_unref (context->palette);
     }
 
@@ -2781,7 +2806,14 @@ gimp_context_real_set_palette (GimpConte
 
   if (palette)
     {
+      GError *error = NULL;
       g_object_ref (palette);
+
+      if (!gimp_data_load (GIMP_DATA (palette), &error))
+        {
+          fprintf (stderr, "%s\n", error->message);
+          g_error_free (error);
+        }
 
       g_signal_connect_object (palette, "name-changed",
                                G_CALLBACK (gimp_context_palette_dirty),
Index: app/core/gimpdata.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpdata.c,v
retrieving revision 1.49
diff -u -3 -p -r1.49 gimpdata.c
--- app/core/gimpdata.c	1 Nov 2005 13:04:09 -0000	1.49
+++ app/core/gimpdata.c	7 Feb 2006 11:01:30 -0000
@@ -148,6 +148,8 @@ gimp_data_class_init (GimpDataClass *kla
   klass->save                     = NULL;
   klass->get_extension            = NULL;
   klass->duplicate                = NULL;
+  klass->load                     = NULL;
+  klass->unload                   = NULL;
 
   g_object_class_install_property (object_class, PROP_FILENAME,
 				   g_param_spec_string ("filename", NULL, NULL,
@@ -183,6 +185,7 @@ gimp_data_init (GimpData      *data,
   data->internal     = FALSE;
   data->freeze_count = 0;
   data->mtime        = 0;
+  data->load_count   = 0;
 
   /*  look at the passed class pointer, not at GIMP_DATA_GET_CLASS(data)
    *  here, because the latter is always GimpDataClass itself
@@ -699,3 +702,50 @@ gimp_data_error_quark (void)
 
   return quark;
 }
+
+/**
+ * gimp_data_load:
+ * @data:  object whose contents are to be loaded.
+ *
+ * Loads the contents of the object.
+ **/
+gboolean
+gimp_data_load (GimpData  *data,
+                GError   **error)
+{
+  g_return_val_if_fail (GIMP_IS_DATA (data), FALSE);
+
+  if (data->load_count == 0)
+    {
+      if (GIMP_DATA_GET_CLASS (data)->load)
+        {
+          if (! GIMP_DATA_GET_CLASS (data)->load (data, error))
+            {
+              return FALSE;
+            }
+        }
+    }
+  data->load_count++;
+  return TRUE;
+}
+
+/**
+ * gimp_data_unload:
+ * @data:  object whose contents are to be unloaded.
+ *
+ * Unloads the contents of the object. If the object's load count is 0, its
+ * memory will be freed.
+ **/
+void
+gimp_data_unload (GimpData  *data)
+{
+  g_return_if_fail (GIMP_IS_DATA (data));
+
+  data->load_count--;
+  if (data->load_count == 0)
+    {
+      if (GIMP_DATA_GET_CLASS (data)->unload)
+        GIMP_DATA_GET_CLASS (data)->unload (data);
+    }
+}
+
Index: app/core/gimpdata.h
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpdata.h,v
retrieving revision 1.23
diff -u -3 -p -r1.23 gimpdata.h
--- app/core/gimpdata.h	31 Oct 2005 11:29:00 -0000	1.23
+++ app/core/gimpdata.h	7 Feb 2006 11:01:30 -0000
@@ -58,6 +58,7 @@ struct _GimpData
   guint         internal  : 1;
   gint          freeze_count;
   time_t        mtime;
+  gint          load_count;
 };
 
 struct _GimpDataClass
@@ -72,6 +73,9 @@ struct _GimpDataClass
                                 GError   **error);
   gchar    * (* get_extension) (GimpData  *data);
   GimpData * (* duplicate)     (GimpData  *data);
+  gboolean   (* load)          (GimpData  *data,
+                                GError   **ereor);
+  void       (* unload)        (GimpData  *data);
 };
 
 
@@ -108,6 +112,8 @@ gint          gimp_data_name_compare    
 #define GIMP_DATA_ERROR (gimp_data_error_quark ())
 
 GQuark        gimp_data_error_quark      (void) G_GNUC_CONST;
-
+gboolean      gimp_data_load             (GimpData     *data,
+                                          GError      **error);
+void          gimp_data_unload           (GimpData     *data);
 
 #endif /* __GIMP_DATA_H__ */
Index: app/core/gimpdrawable-bucket-fill.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-bucket-fill.c,v
retrieving revision 1.36
diff -u -3 -p -r1.36 gimpdrawable-bucket-fill.c
--- app/core/gimpdrawable-bucket-fill.c	11 Nov 2004 14:05:33 -0000	1.36
+++ app/core/gimpdrawable-bucket-fill.c	7 Feb 2006 11:01:30 -0000
@@ -157,6 +157,13 @@ gimp_drawable_bucket_fill_full (GimpDraw
     }
   else if (fill_mode == GIMP_PATTERN_BUCKET_FILL)
     {
+      GError *error = NULL;
+      if (!gimp_data_load (GIMP_DATA (pattern), &error))
+        {
+          g_clear_error (&error);
+          /* TODO : Put some error handling here. */
+          return;
+        }
       pat_buf = gimp_image_transform_temp_buf (gimage, drawable,
                                                pattern->mask, &new_buf);
     }
@@ -283,6 +290,9 @@ gimp_drawable_bucket_fill_full (GimpDraw
 
   if (new_buf)
     temp_buf_free (pat_buf);
+
+  if (fill_mode == GIMP_PATTERN_BUCKET_FILL)
+    gimp_data_unload (GIMP_DATA (pattern));
 
   gimp_unset_busy (gimage->gimp);
 }
Index: app/core/gimpgradient-load.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpgradient-load.c,v
retrieving revision 1.15
diff -u -3 -p -r1.15 gimpgradient-load.c
--- app/core/gimpgradient-load.c	8 Jun 2005 11:27:31 -0000	1.15
+++ app/core/gimpgradient-load.c	7 Feb 2006 11:01:30 -0000
@@ -43,11 +43,6 @@ gimp_gradient_load (const gchar  *filena
                     GError      **error)
 {
   GimpGradient        *gradient;
-  GimpGradientSegment *seg;
-  GimpGradientSegment *prev;
-  gint                 num_segments;
-  gint                 i;
-  gint                 type, color;
   FILE                *file;
   gchar                line[1024];
 
@@ -92,7 +87,6 @@ gimp_gradient_load (const gchar  *filena
       gimp_object_set_name (GIMP_OBJECT (gradient), utf8);
       g_free (utf8);
 
-      fgets (line, 1024, file);
     }
   else /* old gradient format */
     {
@@ -102,6 +96,45 @@ gimp_gradient_load (const gchar  *filena
       g_free (name);
     }
 
+  gradient->data_offset = ftell(file);
+  fclose(file);
+  return g_list_prepend (NULL, gradient);
+}
+
+gboolean
+gimp_gradient_data_load (GimpData *data,
+                         GError  **error)
+{
+  GimpGradient        *gradient;
+  gint                 num_segments;
+  gint                 type, color;
+  gint                 i;
+  GimpGradientSegment *seg;
+  GimpGradientSegment *prev;
+  FILE                *file;
+  gchar                line[1024];
+
+  gradient = GIMP_GRADIENT (data);
+  /* Do nothing if this is an anonymous gradient that has no presence
+   * on the disk. 
+   * */
+  if (! data->filename)
+    {
+      return TRUE;
+    }
+
+  file = g_fopen (data->filename, "rb");
+  if (!file)
+    {
+      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
+                   _("Could not open '%s' for reading: %s"),
+                   gimp_filename_to_utf8 (data->filename), g_strerror (errno));
+      return FALSE;
+    }
+  
+  fseek(file, gradient->data_offset, SEEK_SET);
+  fgets (line, 1024, file);
+ 
   num_segments = atoi (line);
 
   if (num_segments < 1)
@@ -109,10 +142,10 @@ gimp_gradient_load (const gchar  *filena
       g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
                    _("Fatal parse error in gradient file '%s': "
                      "File is corrupt."),
-                   gimp_filename_to_utf8 (filename));
+                   gimp_filename_to_utf8 (data->filename));
       g_object_unref (gradient);
       fclose (file);
-      return NULL;
+      return FALSE;
     }
 
   prev = NULL;
@@ -165,10 +198,10 @@ gimp_gradient_load (const gchar  *filena
       else
         {
 	  g_message (_("Corrupt segment %d in gradient file '%s'."),
-		     i, gimp_filename_to_utf8 (filename));
+		     i, gimp_filename_to_utf8 (data->filename));
           g_object_unref (gradient);
           fclose (file);
-          return NULL;
+          return FALSE;
 	}
 
       if ( (prev && (prev->right < seg->left))
@@ -177,10 +210,10 @@ gimp_gradient_load (const gchar  *filena
           g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
                        _("Gradient file '%s' is corrupt: "
                          "Segments do not span the range 0-1."),
-                       gimp_filename_to_utf8 (filename));
+                       gimp_filename_to_utf8 (data->filename));
           g_object_unref (gradient);
           fclose (file);
-          return NULL;
+          return FALSE;
         }
 
       prev = seg;
@@ -191,15 +224,15 @@ gimp_gradient_load (const gchar  *filena
       g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
                    _("Gradient file '%s' is corrupt: "
                      "Segments do not span the range 0-1."),
-                   gimp_filename_to_utf8 (filename));
+                   gimp_filename_to_utf8 (data->filename));
       g_object_unref (gradient);
       fclose (file);
-      return NULL;
+      return FALSE;
     }
 
   fclose (file);
-
-  return g_list_prepend (NULL, gradient);
+  
+  return TRUE;
 }
 
 
Index: app/core/gimpgradient.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpgradient.c,v
retrieving revision 1.58
diff -u -3 -p -r1.58 gimpgradient.c
--- app/core/gimpgradient.c	10 Dec 2005 19:24:35 -0000	1.58
+++ app/core/gimpgradient.c	7 Feb 2006 11:01:30 -0000
@@ -77,6 +77,8 @@ static inline gdouble  gimp_gradient_cal
 static inline gdouble  gimp_gradient_calc_sphere_decreasing_factor (gdouble  middle,
                                                                     gdouble  pos);
 
+static void gimp_gradient_data_unload (GimpData *);
+
 
 G_DEFINE_TYPE (GimpGradient, gimp_gradient, GIMP_TYPE_DATA);
 
@@ -103,6 +105,8 @@ gimp_gradient_class_init (GimpGradientCl
   data_class->save                 = gimp_gradient_save;
   data_class->get_extension        = gimp_gradient_get_extension;
   data_class->duplicate            = gimp_gradient_duplicate;
+  data_class->load                 = gimp_gradient_data_load;
+  data_class->unload               = gimp_gradient_data_unload;
 }
 
 static void
@@ -221,6 +225,13 @@ gimp_gradient_duplicate (GimpData *data)
 {
   GimpGradient        *gradient;
   GimpGradientSegment *head, *prev, *cur, *orig;
+  GError              *error = NULL;
+
+  if (!gimp_data_load (data, &error))
+    {
+      g_clear_error (&error);
+      return NULL;
+    }
 
   gradient = g_object_new (GIMP_TYPE_GRADIENT, NULL);
 
@@ -248,6 +259,8 @@ gimp_gradient_duplicate (GimpData *data)
 
   gradient->segments = head;
 
+  gimp_data_unload (data);
+
   return GIMP_DATA (gradient);
 }
 
@@ -1797,3 +1810,19 @@ gimp_gradient_calc_sphere_decreasing_fac
   /* Works for convex decreasing and concave increasing */
   return 1.0 - sqrt(1.0 - pos * pos);
 }
+
+static void
+gimp_gradient_data_unload (GimpData *data)
+{
+  GimpGradient *gradient;
+  gradient = GIMP_GRADIENT (data);
+  /* Do nothing if this is an anonymous gradient that has no presence
+   * on the disk. 
+   * */
+  if (! data->filename)
+    return;
+
+  gimp_gradient_segments_free (gradient->segments);
+  gradient->segments = NULL;
+}
+
Index: app/core/gimpgradient.h
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpgradient.h,v
retrieving revision 1.20
diff -u -3 -p -r1.20 gimpgradient.h
--- app/core/gimpgradient.h	8 Jun 2005 11:27:31 -0000	1.20
+++ app/core/gimpgradient.h	7 Feb 2006 11:01:30 -0000
@@ -56,6 +56,8 @@ struct _GimpGradient
 {
   GimpData             parent_instance;
 
+  guint32              data_offset;
+
   GimpGradientSegment *segments;
 };
 
@@ -224,5 +226,6 @@ gdouble gimp_gradient_segment_range_move
                                                gdouble               delta,
                                                gboolean              control_compress);
 
+gboolean gimp_gradient_data_load (GimpData *, GError **error);
 
 #endif /* __GIMP_GRADIENT_H__ */
Index: app/core/gimppalette.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimppalette.c,v
retrieving revision 1.63
diff -u -3 -p -r1.63 gimppalette.c
--- app/core/gimppalette.c	10 Dec 2005 19:24:35 -0000	1.63
+++ app/core/gimppalette.c	7 Feb 2006 11:01:30 -0000
@@ -71,7 +71,9 @@ static gchar    * gimp_palette_get_exten
 static GimpData * gimp_palette_duplicate        (GimpData          *data);
 
 static void       gimp_palette_entry_free       (GimpPaletteEntry  *entry);
-
+static gboolean   gimp_palette_data_load        (GimpData          *data,
+                                                 GError           **error);
+static void       gimp_palette_data_unload      (GimpData          *data);
 
 G_DEFINE_TYPE (GimpPalette, gimp_palette, GIMP_TYPE_DATA);
 
@@ -99,6 +101,8 @@ gimp_palette_class_init (GimpPaletteClas
   data_class->save                 = gimp_palette_save;
   data_class->get_extension        = gimp_palette_get_extension;
   data_class->duplicate            = gimp_palette_duplicate;
+  data_class->load                 = gimp_palette_data_load;
+  data_class->unload               = gimp_palette_data_unload;
 }
 
 static void
@@ -206,6 +210,13 @@ gimp_palette_get_new_preview (GimpViewab
   gint         rows;
   gint         cell_size;
   gint         x, y;
+  GError      *error = NULL;
+
+  if (!gimp_data_load (GIMP_DATA (palette), &error))
+    {
+      g_clear_error (&error);
+      return NULL;
+    }
 
   temp_buf = temp_buf_new (width, height, 3, 0, 0, white);
 
@@ -251,6 +262,8 @@ gimp_palette_get_new_preview (GimpViewab
         memcpy (buf + ((y * cell_size + i) * width) * 3, b, width * 3);
     }
 
+  gimp_data_unload (GIMP_DATA (palette));
+
   g_free (b);
 
   return temp_buf;
@@ -301,19 +314,14 @@ gimp_palette_load (const gchar  *filenam
                    GError      **error)
 {
   GimpPalette      *palette;
-  GimpPaletteEntry *entry;
   gchar             str[1024];
-  gchar            *tok;
   FILE             *file;
-  gint              r, g, b;
   gint              linenum;
 
   g_return_val_if_fail (filename != NULL, NULL);
   g_return_val_if_fail (g_path_is_absolute (filename), NULL);
   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-  r = g = b = 0;
-
   file = g_fopen (filename, "r");
 
   if (! file)
@@ -366,6 +374,9 @@ gimp_palette_load (const gchar  *filenam
 
   linenum++;
 
+  palette->data_offset = ftell(file);
+  palette->data_linenum = linenum;
+
   if (! strncmp (str, "Name: ", strlen ("Name: ")))
     {
       gchar *utf8;
@@ -408,6 +419,9 @@ gimp_palette_load (const gchar  *filenam
 
           palette->n_columns = columns;
 
+          palette->data_offset = ftell(file);
+          palette->data_linenum = linenum;        
+
           if (! fgets (str, sizeof (str), file))
             {
               g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
@@ -418,7 +432,6 @@ gimp_palette_load (const gchar  *filenam
               g_object_unref (palette);
               return NULL;
             }
-
           linenum++;
         }
     }
@@ -428,8 +441,65 @@ gimp_palette_load (const gchar  *filenam
 
       gimp_object_set_name (GIMP_OBJECT (palette), name);
       g_free (name);
+      palette->data_offset = ftell(file);
+      palette->data_linenum = linenum;
     }
 
+  fclose (file);
+  
+  return g_list_prepend (NULL, palette);
+}
+
+static gboolean
+gimp_palette_data_load        (GimpData          *data,
+                               GError           **error)
+{
+  GimpPalette      *palette;
+  FILE             *file;
+  gchar            *tok;
+  GimpPaletteEntry *entry;
+  gchar             str[1024];
+  gint              r, g, b;
+  gint              linenum;
+  gint              n_colors;
+
+  /* Handle the case of the "Standard" palette. */
+  if (! data->filename)
+    {
+      return TRUE;
+    }
+
+  palette = GIMP_PALETTE (data);
+
+  r = g = b = 0;
+
+  file = g_fopen (data->filename, "r");
+  if (! file)
+    {
+      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
+                   _("Could not open '%s' for reading: %s"),
+                   gimp_filename_to_utf8 (data->filename), g_strerror (errno));
+      return FALSE;
+    }
+
+  fseek (file, palette->data_offset, SEEK_SET);
+  linenum = palette->data_linenum;
+
+  if (! fgets (str, sizeof (str), file))
+    {
+      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
+                   _("Fatal parse error in palette file '%s': "
+                     "Read error in line %d."),
+                   gimp_filename_to_utf8 (data->filename), linenum);
+      fclose (file);
+      g_object_unref (palette);
+      return FALSE;
+    }
+
+  linenum++;
+  
+  n_colors = 0;
+
   while (! feof (file))
     {
       if (str[0] != '#')
@@ -441,7 +511,7 @@ gimp_palette_load (const gchar  *filenam
             /* maybe we should just abort? */
             g_message (_("Reading palette file '%s': "
                          "Missing RED component in line %d."),
-                       gimp_filename_to_utf8 (filename), linenum);
+                       gimp_filename_to_utf8 (data->filename), linenum);
 
           tok = strtok (NULL, " \t");
           if (tok)
@@ -449,7 +519,7 @@ gimp_palette_load (const gchar  *filenam
           else
             g_message (_("Reading palette '%s': "
                          "Missing GREEN component in line %d."),
-                       gimp_filename_to_utf8 (filename), linenum);
+                       gimp_filename_to_utf8 (data->filename), linenum);
 
           tok = strtok (NULL, " \t");
           if (tok)
@@ -457,7 +527,7 @@ gimp_palette_load (const gchar  *filenam
           else
             g_message (_("Reading palette file '%s': "
                          "Missing BLUE component in line %d."),
-                       gimp_filename_to_utf8 (filename), linenum);
+                       gimp_filename_to_utf8 (data->filename), linenum);
 
           /* optional name */
           tok = strtok (NULL, "\n");
@@ -467,7 +537,7 @@ gimp_palette_load (const gchar  *filenam
               b < 0 || b > 255)
             g_message (_("Reading palette file '%s': "
                          "RGB value out of range in line %d."),
-                       gimp_filename_to_utf8 (filename), linenum);
+                       gimp_filename_to_utf8 (data->filename), linenum);
 
           /* don't call gimp_palette_add_entry here, it's rather inefficient */
           entry = g_new0 (GimpPaletteEntry, 1);
@@ -479,10 +549,10 @@ gimp_palette_load (const gchar  *filenam
                                255);
 
           entry->name     = g_strdup (tok ? tok : _("Untitled"));
-          entry->position = palette->n_colors;
+          entry->position = n_colors;
 
           palette->colors = g_list_prepend (palette->colors, entry);
-          palette->n_colors++;
+          n_colors++;
         }
 
       if (! fgets (str, sizeof (str), file))
@@ -493,20 +563,20 @@ gimp_palette_load (const gchar  *filenam
           g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
                        _("Fatal parse error in palette file '%s': "
                          "Read error in line %d."),
-                       gimp_filename_to_utf8 (filename), linenum);
+                       gimp_filename_to_utf8 (data->filename), linenum);
           fclose (file);
           g_object_unref (palette);
-          return NULL;
+          return FALSE;
         }
 
       linenum++;
     }
-
   fclose (file);
 
   palette->colors = g_list_reverse (palette->colors);
+  palette->n_colors = n_colors;
 
-  return g_list_prepend (NULL, palette);
+  return TRUE;
 }
 
 static gboolean
@@ -517,6 +587,11 @@ gimp_palette_save (GimpData  *data,
   GList       *list;
   FILE        *file;
 
+  if (!gimp_data_load (GIMP_DATA (palette), error))
+    {
+      return FALSE;
+    }
+
   file = g_fopen (data->filename, "w");
 
   if (! file)
@@ -542,6 +617,8 @@ gimp_palette_save (GimpData  *data,
       fprintf (file, "%3d %3d %3d\t%s\n", r, g, b, entry->name);
     }
 
+  gimp_data_unload (GIMP_DATA (palette));
+
   fclose (file);
 
   return TRUE;
@@ -689,3 +766,28 @@ gimp_palette_entry_free (GimpPaletteEntr
   g_free (entry->name);
   g_free (entry);
 }
+
+
+
+static void       gimp_palette_data_unload      (GimpData          *data)
+{
+  GimpPalette *palette;
+  /* Handle the case of the "Standard" palette */
+  if (! data->filename)
+    {
+      return;
+    }
+  /* A Palette can be modified, and thus its data should not be removed */
+  if (data->dirty)
+    {
+      return;
+    }
+  palette = GIMP_PALETTE (data);
+  if (palette->colors)
+    {
+      g_list_foreach (palette->colors, (GFunc) gimp_palette_entry_free, NULL);
+      g_list_free (palette->colors);
+      palette->colors = NULL;
+    }
+}
+
Index: app/core/gimppalette.h
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimppalette.h,v
retrieving revision 1.26
diff -u -3 -p -r1.26 gimppalette.h
--- app/core/gimppalette.h	1 Sep 2005 18:06:21 -0000	1.26
+++ app/core/gimppalette.h	7 Feb 2006 11:01:30 -0000
@@ -50,6 +50,8 @@ struct _GimpPalette
 {
   GimpData  parent_instance;
 
+  guint32   data_offset;
+  gint      data_linenum;
   GList    *colors;
   gint      n_colors;
 
Index: app/core/gimppattern.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimppattern.c,v
retrieving revision 1.61
diff -u -3 -p -r1.61 gimppattern.c
--- app/core/gimppattern.c	10 Dec 2005 19:24:35 -0000	1.61
+++ app/core/gimppattern.c	7 Feb 2006 11:01:30 -0000
@@ -76,6 +76,8 @@ G_DEFINE_TYPE (GimpPattern, gimp_pattern
 
 #define parent_class gimp_pattern_parent_class
 
+static gboolean gimp_pattern_data_load (GimpData *, GError **);
+static void gimp_pattern_data_unload (GimpData *);
 
 static void
 gimp_pattern_class_init (GimpPatternClass *klass)
@@ -96,6 +98,8 @@ gimp_pattern_class_init (GimpPatternClas
 
   data_class->get_extension        = gimp_pattern_get_extension;
   data_class->duplicate            = gimp_pattern_duplicate;
+  data_class->load                 = gimp_pattern_data_load;
+  data_class->unload               = gimp_pattern_data_unload;
 }
 
 static void
@@ -139,8 +143,8 @@ gimp_pattern_get_size (GimpViewable *vie
 {
   GimpPattern *pattern = GIMP_PATTERN (viewable);
 
-  *width  = pattern->mask->width;
-  *height = pattern->mask->height;
+  *width  = pattern->width;
+  *height = pattern->height;
 
   return TRUE;
 }
@@ -154,6 +158,14 @@ gimp_pattern_get_new_preview (GimpViewab
   TempBuf     *temp_buf;
   gint         copy_width;
   gint         copy_height;
+  GError      *error = NULL;
+
+  if (! gimp_data_load (GIMP_DATA (pattern), &error))
+    {
+      g_clear_error (&error);
+      /* TODO : Error handling */
+      return NULL;
+    }
 
   copy_width  = MIN (width,  pattern->mask->width);
   copy_height = MIN (height, pattern->mask->height);
@@ -165,6 +177,7 @@ gimp_pattern_get_new_preview (GimpViewab
   temp_buf_copy_area (pattern->mask, temp_buf,
                       0, 0, copy_width, copy_height, 0, 0);
 
+  gimp_data_unload (GIMP_DATA (pattern));
   return temp_buf;
 }
 
@@ -176,8 +189,8 @@ gimp_pattern_get_description (GimpViewab
 
   return g_strdup_printf ("%s (%d x %d)",
                           GIMP_OBJECT (pattern)->name,
-                          pattern->mask->width,
-                          pattern->mask->height);
+                          pattern->width,
+                          pattern->height);
 }
 
 static gchar *
@@ -339,19 +352,10 @@ gimp_pattern_load (const gchar  *filenam
 
   g_free (name);
 
-  pattern->mask = temp_buf_new (header.width, header.height, header.bytes,
-                                0, 0, NULL);
-  if (read (fd, temp_buf_data (pattern->mask),
-            header.width * header.height * header.bytes) <
-      header.width * header.height * header.bytes)
-    {
-      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
-                   _("Fatal parse error in pattern file '%s': "
-                     "File appears truncated."),
-                   gimp_filename_to_utf8 (filename));
-      goto error;
-    }
-
+  pattern->width = header.width;
+  pattern->height = header.height;
+  pattern->bytes = header.bytes;
+  pattern->data_offset = lseek(fd, 0, SEEK_CUR);
   close (fd);
 
   return g_list_prepend (NULL, pattern);
@@ -431,3 +435,63 @@ gimp_pattern_get_mask (const GimpPattern
 
   return pattern->mask;
 }
+
+static gboolean
+gimp_pattern_data_load(GimpData  *data_pat,
+                       GError   **error)
+{
+  GimpPattern *pattern;
+  int fd;
+
+  /* Check for the standard pattern */
+  if (! data_pat->filename)
+    {
+      return TRUE;
+    }
+
+  pattern = GIMP_PATTERN (data_pat);
+  fd = g_open (data_pat->filename, O_RDONLY | _O_BINARY, 0);
+  if (fd == -1)
+    {
+      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
+                   _("Could not open '%s' for reading: %s"),
+                   gimp_filename_to_utf8 (data_pat->filename),
+                   g_strerror (errno));
+      return FALSE;
+    }
+  lseek (fd, pattern->data_offset, SEEK_SET);
+  pattern->mask = temp_buf_new (pattern->width, pattern->height,
+                                pattern->bytes, 0, 0, NULL);
+  if (read (fd, temp_buf_data (pattern->mask),
+            pattern->width * pattern->height * pattern->bytes) <
+      pattern->width * pattern->height * pattern->bytes)
+    {
+      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
+                   _("Fatal parse error in pattern file '%s': "
+                     "File appears truncated."),
+                   gimp_filename_to_utf8 (data_pat->filename));
+      goto error;
+    }
+
+  close(fd);
+  return TRUE;
+error:
+  close(fd);
+  return FALSE;
+}
+
+static void gimp_pattern_data_unload(GimpData * data_pat)
+{
+  GimpPattern *pattern;
+
+  /* Handle the case of the "Standard" pattern */
+  if (! data_pat->filename)
+    {
+      return;
+    }
+
+  pattern = GIMP_PATTERN (data_pat);
+  temp_buf_free (pattern->mask);
+  pattern->mask = NULL;
+}
+
Index: app/core/gimppattern.h
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimppattern.h,v
retrieving revision 1.15
diff -u -3 -p -r1.15 gimppattern.h
--- app/core/gimppattern.h	8 Jun 2005 11:27:31 -0000	1.15
+++ app/core/gimppattern.h	7 Feb 2006 11:01:30 -0000
@@ -40,6 +40,11 @@ struct _GimpPattern
 {
   GimpData  parent_instance;
 
+  guint32   width;
+  guint32   height;
+  guint32   bytes;
+  guint32   data_offset;
+
   TempBuf  *mask;
 };
 
Index: app/paint/gimpclone.c
===================================================================
RCS file: /cvs/gnome/gimp/app/paint/gimpclone.c,v
retrieving revision 1.127
diff -u -3 -p -r1.127 gimpclone.c
--- app/paint/gimpclone.c	27 Dec 2005 18:56:25 -0000	1.127
+++ app/paint/gimpclone.c	7 Feb 2006 11:01:30 -0000
@@ -442,7 +442,7 @@ gimp_clone_line_pattern (GimpImage    *d
   gint               pat_bytes;
   gint               i;
 
-  pat_bytes = pattern->mask->bytes;
+  pat_bytes = pattern->bytes;
 
   /*  Make sure x, y are positive  */
   while (x < 0)
Index: app/pdb/gradient_cmds.c
===================================================================
RCS file: /cvs/gnome/gimp/app/pdb/gradient_cmds.c,v
retrieving revision 1.9
diff -u -3 -p -r1.9 gradient_cmds.c
--- app/pdb/gradient_cmds.c	5 Aug 2005 18:19:09 -0000	1.9
+++ app/pdb/gradient_cmds.c	7 Feb 2006 11:01:35 -0000
@@ -192,14 +192,29 @@ gradient_duplicate_invoker (Gimp        
 
       if (gradient)
         {
-          gradient_copy = (GimpGradient *)
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      gradient_copy = (GimpGradient *)
             gimp_data_factory_data_duplicate (gimp->gradient_factory,
                                               GIMP_DATA (gradient));
 
           success = (gradient_copy != NULL);
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_duplicate_proc, success);
@@ -267,9 +282,26 @@ gradient_is_editable_invoker (Gimp      
         gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
 
       if (gradient)
-        success = TRUE;
-      else
+        {
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                    success = TRUE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
+        }
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_is_editable_proc, success);
@@ -341,10 +373,31 @@ gradient_rename_invoker (Gimp         *g
       gradient = (GimpGradient *)
         gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
 
-      if (gradient && GIMP_DATA (gradient)->writable)
+      if (gradient)
+        {
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+
+      if (GIMP_DATA (gradient)->writable)
         gimp_object_set_name (GIMP_OBJECT (gradient), new_name);
       else
         success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
+        }
+        else
+        success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_rename_proc, success);
@@ -415,7 +468,19 @@ gradient_delete_invoker (Gimp         *g
       gradient = (GimpGradient *)
         gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
 
-      if (gradient && GIMP_DATA (gradient)->deletable)
+      if (gradient)
+        {
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                  if (GIMP_DATA (gradient)->deletable)
         {
           GError *error = NULL;
 
@@ -431,6 +496,14 @@ gradient_delete_invoker (Gimp         *g
         }
       else
         success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
+        }
+        else
+        success = FALSE;
+
     }
 
   return procedural_db_return_args (&gradient_delete_proc, success);
@@ -495,7 +568,17 @@ gradient_get_uniform_samples_invoker (Gi
 
       if (gradient)
         {
-          GimpGradientSegment *seg   = NULL;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg   = NULL;
           gdouble              pos   = 0.0;
           gdouble              delta = 1.0 / (num_samples - 1);
           gdouble             *sample;
@@ -517,9 +600,14 @@ gradient_get_uniform_samples_invoker (Gi
 
               pos += delta;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_get_uniform_samples_proc, success);
@@ -619,7 +707,17 @@ gradient_get_custom_samples_invoker (Gim
 
       if (gradient)
         {
-          GimpGradientSegment *seg = NULL;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg = NULL;
           gdouble             *sample;
 
           num_color_samples = num_samples * 4;
@@ -639,9 +737,14 @@ gradient_get_custom_samples_invoker (Gim
 
               pos++;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_get_custom_samples_proc, success);
@@ -740,7 +843,17 @@ gradient_segment_get_left_color_invoker 
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -751,9 +864,14 @@ gradient_segment_get_left_color_invoker 
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_get_left_color_proc, success);
@@ -847,7 +965,17 @@ gradient_segment_set_left_color_invoker 
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -858,9 +986,14 @@ gradient_segment_set_left_color_invoker 
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return procedural_db_return_args (&gradient_segment_set_left_color_proc, success);
@@ -937,7 +1070,17 @@ gradient_segment_get_right_color_invoker
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -948,9 +1091,14 @@ gradient_segment_get_right_color_invoker
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_get_right_color_proc, success);
@@ -1044,7 +1192,17 @@ gradient_segment_set_right_color_invoker
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -1055,9 +1213,14 @@ gradient_segment_set_right_color_invoker
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return procedural_db_return_args (&gradient_segment_set_right_color_proc, success);
@@ -1133,7 +1296,17 @@ gradient_segment_get_left_pos_invoker (G
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -1143,9 +1316,14 @@ gradient_segment_get_left_pos_invoker (G
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_get_left_pos_proc, success);
@@ -1230,7 +1408,17 @@ gradient_segment_set_left_pos_invoker (G
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -1241,9 +1429,14 @@ gradient_segment_set_left_pos_invoker (G
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_set_left_pos_proc, success);
@@ -1328,7 +1521,17 @@ gradient_segment_get_middle_pos_invoker 
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -1338,9 +1541,14 @@ gradient_segment_get_middle_pos_invoker 
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_get_middle_pos_proc, success);
@@ -1425,7 +1633,17 @@ gradient_segment_set_middle_pos_invoker 
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -1436,9 +1654,14 @@ gradient_segment_set_middle_pos_invoker 
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_set_middle_pos_proc, success);
@@ -1523,7 +1746,17 @@ gradient_segment_get_right_pos_invoker (
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -1533,9 +1766,14 @@ gradient_segment_get_right_pos_invoker (
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_get_right_pos_proc, success);
@@ -1620,7 +1858,17 @@ gradient_segment_set_right_pos_invoker (
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -1631,9 +1879,14 @@ gradient_segment_set_right_pos_invoker (
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_set_right_pos_proc, success);
@@ -1718,7 +1971,17 @@ gradient_segment_get_blending_function_i
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -1729,9 +1992,14 @@ gradient_segment_get_blending_function_i
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_get_blending_function_proc, success);
@@ -1811,7 +2079,17 @@ gradient_segment_get_coloring_type_invok
 
       if (gradient)
         {
-          GimpGradientSegment *seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *seg;
 
           seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
 
@@ -1822,9 +2100,14 @@ gradient_segment_get_coloring_type_invok
             }
           else
             success = FALSE;
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
-      else
+        else
         success = FALSE;
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_get_coloring_type_proc, success);
@@ -1910,7 +2193,17 @@ gradient_segment_range_set_blending_func
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -1944,7 +2237,12 @@ gradient_segment_range_set_blending_func
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_set_blending_function_proc, success);
@@ -2026,7 +2324,17 @@ gradient_segment_range_set_coloring_type
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -2060,7 +2368,12 @@ gradient_segment_range_set_coloring_type
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_set_coloring_type_proc, success);
@@ -2137,7 +2450,17 @@ gradient_segment_range_flip_invoker (Gim
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -2171,7 +2494,12 @@ gradient_segment_range_flip_invoker (Gim
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_flip_proc, success);
@@ -2248,7 +2576,17 @@ gradient_segment_range_replicate_invoker
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -2283,7 +2621,12 @@ gradient_segment_range_replicate_invoker
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_replicate_proc, success);
@@ -2360,7 +2703,17 @@ gradient_segment_range_split_midpoint_in
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -2394,7 +2747,12 @@ gradient_segment_range_split_midpoint_in
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_split_midpoint_proc, success);
@@ -2471,7 +2829,17 @@ gradient_segment_range_split_uniform_inv
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -2506,7 +2874,12 @@ gradient_segment_range_split_uniform_inv
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_split_uniform_proc, success);
@@ -2583,7 +2956,17 @@ gradient_segment_range_delete_invoker (G
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -2617,7 +3000,12 @@ gradient_segment_range_delete_invoker (G
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_delete_proc, success);
@@ -2689,7 +3077,17 @@ gradient_segment_range_redistribute_hand
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -2722,7 +3120,12 @@ gradient_segment_range_redistribute_hand
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_redistribute_handles_proc, success);
@@ -2794,7 +3197,17 @@ gradient_segment_range_blend_colors_invo
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -2829,7 +3242,12 @@ gradient_segment_range_blend_colors_invo
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_blend_colors_proc, success);
@@ -2901,7 +3319,17 @@ gradient_segment_range_blend_opacity_inv
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -2936,7 +3364,12 @@ gradient_segment_range_blend_opacity_inv
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return procedural_db_return_args (&gradient_segment_range_blend_opacity_proc, success);
@@ -3018,7 +3451,17 @@ gradient_segment_range_move_invoker (Gim
 
       if (gradient)
         {
-          GimpGradientSegment *start_seg, *end_seg;
+          GError *error;
+          success = gimp_data_load (GIMP_DATA (gradient), &error);
+          if (!success)
+            {
+              g_message (error->message);
+              g_clear_error (error);
+            }
+          else
+            {
+              {
+                      GimpGradientSegment *start_seg, *end_seg;
           start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                      start_segment);
           if (start_seg)
@@ -3054,7 +3497,12 @@ gradient_segment_range_move_invoker (Gim
             {
               success = FALSE;
             }
+
+              }
+              gimp_data_unload (GIMP_DATA (gradient));
+            }
         }
+
     }
 
   return_args = procedural_db_return_args (&gradient_segment_range_move_proc, success);
Index: app/widgets/gimpviewrendererbrush.c
===================================================================
RCS file: /cvs/gnome/gimp/app/widgets/gimpviewrendererbrush.c,v
retrieving revision 1.34
diff -u -3 -p -r1.34 gimpviewrendererbrush.c
--- app/widgets/gimpviewrendererbrush.c	19 Dec 2005 22:37:49 -0000	1.34
+++ app/widgets/gimpviewrendererbrush.c	7 Feb 2006 11:01:35 -0000
@@ -96,8 +96,8 @@ gimp_view_renderer_brush_render (GimpVie
     }
 
   brush        = GIMP_BRUSH (renderer->viewable);
-  brush_width  = brush->mask->width;
-  brush_height = brush->mask->height;
+  brush_width  = brush->width;
+  brush_height = brush->height;
 
   temp_buf = gimp_viewable_get_new_preview (renderer->viewable,
                                             renderer->width,
Index: app/widgets/gimpviewrenderergradient.c
===================================================================
RCS file: /cvs/gnome/gimp/app/widgets/gimpviewrenderergradient.c,v
retrieving revision 1.11
diff -u -3 -p -r1.11 gimpviewrenderergradient.c
--- app/widgets/gimpviewrenderergradient.c	19 Dec 2005 22:37:49 -0000	1.11
+++ app/widgets/gimpviewrenderergradient.c	7 Feb 2006 11:01:35 -0000
@@ -104,6 +104,7 @@ gimp_view_renderer_gradient_render (Gimp
   gint                      y;
   gdouble                   dx, cur_x;
   GimpRGB                   color;
+  GError                   *error;
 
   rendergrad = GIMP_VIEW_RENDERER_GRADIENT (renderer);
 
@@ -129,6 +130,12 @@ gimp_view_renderer_gradient_render (Gimp
   dx    = (rendergrad->right - rendergrad->left) / (renderer->width - 1);
   cur_x = rendergrad->left;
 
+  if (!gimp_data_load (GIMP_DATA (gradient), &error))
+    {
+      /* TODO : Deal with the error? */
+      return;
+    }
+
   for (x = 0; x < renderer->width; x++)
     {
       guchar r, g, b, a;
@@ -160,6 +167,8 @@ gimp_view_renderer_gradient_render (Gimp
           *odd++ = gimp_render_blend_dark_check[(a << 8) | b];
         }
     }
+
+  gimp_data_unload (GIMP_DATA (gradient));
 
   if (! renderer->buffer)
     renderer->buffer = g_new (guchar, renderer->height * renderer->rowstride);
Index: app/widgets/gimpviewrendererpalette.c
===================================================================
RCS file: /cvs/gnome/gimp/app/widgets/gimpviewrendererpalette.c,v
retrieving revision 1.7
diff -u -3 -p -r1.7 gimpviewrendererpalette.c
--- app/widgets/gimpviewrendererpalette.c	19 Dec 2005 22:37:49 -0000	1.7
+++ app/widgets/gimpviewrendererpalette.c	7 Feb 2006 11:01:35 -0000
@@ -85,11 +85,17 @@ gimp_view_renderer_palette_render (GimpV
   guchar                  *dest_row;
   GList                   *list;
   gint                     y;
+  GError                  *error;
 
   palette = GIMP_PALETTE (renderer->viewable);
 
+  if (!gimp_data_load (GIMP_DATA (palette), &error))
+    {
+      return;
+    }
+
   if (palette->n_colors < 1)
-    return;
+    goto cleanup;
 
   if (! renderer->buffer)
     renderer->buffer = g_new (guchar, renderer->height * renderer->rowstride);
@@ -197,6 +203,9 @@ gimp_view_renderer_palette_render (GimpV
   g_free (row);
 
   renderer->needs_render = FALSE;
+
+cleanup:
+  gimp_data_unload (GIMP_DATA (palette));
 }
 
 
Index: tools/pdbgen/pdb/gradient.pdb
===================================================================
RCS file: /cvs/gnome/gimp/tools/pdbgen/pdb/gradient.pdb,v
retrieving revision 1.12
diff -u -3 -p -r1.12 gradient.pdb
--- tools/pdbgen/pdb/gradient.pdb	26 Feb 2005 23:55:50 -0000	1.12
+++ tools/pdbgen/pdb/gradient.pdb	7 Feb 2006 11:01:49 -0000
@@ -40,6 +40,46 @@ sub gradient_arg () {{
     desc => 'The gradient name'
 }}
 
+sub _get_gradient_code
+{
+    my $code = shift;
+    my $success_code = shift || "";
+    return <<"CODE";
+{
+  gradient = (GimpGradient *)
+    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
+
+  if (gradient)
+    {
+      GError *error;
+      success = gimp_data_load (GIMP_DATA (gradient), &error);
+      if (!success)
+        {
+          g_message (error->message);
+          g_clear_error (error);
+        }
+      else
+        {
+          {
+            $code
+          }
+          gimp_data_unload (GIMP_DATA (gradient));
+        }
+    }
+  $success_code
+}
+CODE
+}
+
+sub _get_gradient_code_with_success
+{
+    my $code = shift;
+    return _get_gradient_code($code, <<'SUCCESS');
+  else
+    success = FALSE;
+SUCCESS
+}
+
 sub _gen_gradient_search_for_segment_code
 {
     my $action_on_success = shift;
@@ -51,13 +91,7 @@ sub _gen_gradient_search_for_segment_cod
 
     $action_on_success =~ s/^$indent/' ' x 10/meg;
 
-    return <<"CODE";
-{
-  gradient = (GimpGradient *)
-    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
-
-  if (gradient)
-    {
+    return _get_gradient_code_with_success(<<"CODE");
       GimpGradientSegment *seg;
 
       seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
@@ -68,11 +102,6 @@ $action_on_success
         }
       else
         success = FALSE;
-    }
-  else
-    success = FALSE;
-}
-
 CODE
 }
 
@@ -304,22 +333,12 @@ sub gradient_duplicate {
     %invoke = (
 	vars => [ 'GimpGradient *gradient = NULL',
                   'GimpGradient *gradient_copy = NULL' ],
-        code => <<"CODE"
-{
-  gradient = (GimpGradient *)
-    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
-
-  if (gradient)
-    {
+        code => _get_gradient_code_with_success(<<"CODE"),
       gradient_copy = (GimpGradient *)
         gimp_data_factory_data_duplicate (gimp->gradient_factory,
                                           GIMP_DATA (gradient));
 
       success = (gradient_copy != NULL);
-    }
-  else
-    success = FALSE;
-}
 CODE
     );
 }
@@ -343,16 +362,8 @@ sub gradient_is_editable {
 
     %invoke = (
 	vars => [ 'GimpGradient *gradient = NULL' ],
-        code => <<'CODE'
-{
-  gradient = (GimpGradient *)
-    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
-
-  if (gradient)
+        code => _get_gradient_code_with_success(<<'CODE'),
     success = TRUE;
-  else
-    success = FALSE;
-}
 CODE
     );
 }
@@ -377,16 +388,13 @@ sub gradient_rename {
 
     %invoke = (
 	vars => [ 'GimpGradient *gradient = NULL' ],
-	code => <<"CODE"
-{
-  gradient = (GimpGradient *)
-    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
+	code => _get_gradient_code_with_success(<<"CODE"),
 
-  if (gradient && GIMP_DATA (gradient)->writable)
+  if (GIMP_DATA (gradient)->writable)
     gimp_object_set_name (GIMP_OBJECT (gradient), new_name);
   else
     success = FALSE;
-}
+
 CODE
     );
 }
@@ -403,12 +411,8 @@ sub gradient_delete {
 
     %invoke = (
 	vars => [ 'GimpGradient *gradient = NULL' ],
-	code => <<"CODE"
-{
-  gradient = (GimpGradient *)
-    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
-
-  if (gradient && GIMP_DATA (gradient)->deletable)
+	code => _get_gradient_code_with_success(<<"CODE"),
+  if (GIMP_DATA (gradient)->deletable)
     {
       GError *error = NULL;
 
@@ -424,7 +428,6 @@ sub gradient_delete {
     }
   else
     success = FALSE;
-}
 CODE
     );
 }
@@ -474,13 +477,7 @@ HELP
 
     %invoke = (
 	vars => [ 'GimpGradient *gradient' ],
-	code => <<'CODE'
-{
-  gradient = (GimpGradient *)
-    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
-
-  if (gradient)
-    {
+	code => _get_gradient_code_with_success(<<'CODE'),
       GimpGradientSegment *seg   = NULL;
       gdouble              pos   = 0.0;
       gdouble              delta = 1.0 / (num_samples - 1);
@@ -503,10 +500,6 @@ HELP
 
           pos += delta;
         }
-    }
-  else
-    success = FALSE;
-}
 CODE
     );
 }
@@ -539,13 +532,7 @@ HELP
 
     %invoke = (
 	vars => [ 'GimpGradient *gradient' ],
-	code => <<'CODE'
-{
-  gradient = (GimpGradient *)
-    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
-
-  if (gradient)
-    {
+	code => _get_gradient_code_with_success(<<'CODE'),
       GimpGradientSegment *seg = NULL;
       gdouble             *sample;
 
@@ -566,10 +553,6 @@ HELP
 
           pos++;
         }
-    }
-  else
-    success = FALSE;
-}
 CODE
     );
 }
@@ -711,13 +694,7 @@ sub _gen_gradient_operate_on_segments_ra
 
     %invoke = (
         vars => [ 'GimpGradient *gradient = NULL' ],
-        code => <<"CODE",
-{
-  gradient = (GimpGradient *)
-    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
-
-  if (gradient)
-    {
+        code => _get_gradient_code(<<"CODE"),
       GimpGradientSegment *start_seg, *end_seg;
       start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                  start_segment);
@@ -749,8 +726,6 @@ $action_on_success
         {
           success = FALSE;
         }
-    }
-}
 CODE
     );
 }
