From 1098eabc701ce4334caaf0b6ada3fd3d3bb0293e Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 28 Mar 2012 16:59:02 +0200 Subject: [PATCH] app: use the same indexed Babl formats during an image's lifetime And only reconfigure them when the colormap changes. This way undo/redo of layer adding/removing works across type conversions, because the layers need to be in the same format as the image's indexed format. --- app/core/gimpimage-colormap.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/core/gimpimage-colormap.c b/app/core/gimpimage-colormap.c index fbcb887819..67168a1895 100644 --- a/app/core/gimpimage-colormap.c +++ b/app/core/gimpimage-colormap.c @@ -71,10 +71,14 @@ gimp_image_colormap_init (GimpImage *image) private->colormap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE); private->palette = GIMP_PALETTE (gimp_palette_new (NULL, palette_name)); - /* FIXME name palette */ - babl_new_palette (NULL, &private->babl_palette_rgb, &private->babl_palette_rgba); + if (! private->babl_palette_rgb) + { + babl_new_palette (NULL, + &private->babl_palette_rgb, + &private->babl_palette_rgba); + } - gimp_palette_set_columns (private->palette, 16); + gimp_palette_set_columns (private->palette, 16); gimp_data_make_internal (GIMP_DATA (private->palette), palette_id); @@ -122,10 +126,10 @@ gimp_image_colormap_free (GimpImage *image) g_object_unref (private->palette); private->palette = NULL; - babl_palette_reset (private->babl_palette_rgb); - babl_palette_reset (private->babl_palette_rgba); - private->babl_palette_rgb = NULL; - private->babl_palette_rgba = NULL; + /* don't touch the image's babl_palettes because we might still have + * buffers with that palette on the undo stack, and on undoing the + * image back to indexed, we must have exactly these palettes around + */ } const Babl *