[gimp] Bug 626492 - XCF version not increased when new layers are in layer group



commit bb40aef9bfe45cf34098472c2a2325fdc53c6711
Author: Michael Natterer <mitch gimp org>
Date:   Tue Aug 24 14:04:31 2010 +0200

    Bug 626492 - XCF version not increased when new layers are in layer group
    
    Set the XCF version to 3 when saving an image with layer groups and
    add a version 3 loader entry.

 app/xcf/xcf-save.c |   13 ++++++++++---
 app/xcf/xcf.c      |    3 ++-
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c
index b14ceef..ad559c8 100644
--- a/app/xcf/xcf-save.c
+++ b/app/xcf/xcf-save.c
@@ -181,11 +181,12 @@ xcf_save_choose_format (XcfInfo   *info,
   GList *list;
   gint   save_version = 0;  /* default to oldest */
 
+  /* need version 1 for colormaps */
   if (gimp_image_get_colormap (image))
-    save_version = 1;  /* need version 1 for colormaps */
+    save_version = 1;
 
   for (list = gimp_image_get_layer_iter (image);
-       list && save_version < 2;
+       list && save_version < 3;
        list = g_list_next (list))
     {
       GimpLayer *layer = GIMP_LAYER (list->data);
@@ -197,14 +198,20 @@ xcf_save_choose_format (XcfInfo   *info,
         case GIMP_GRAIN_EXTRACT_MODE:
         case GIMP_GRAIN_MERGE_MODE:
         case GIMP_COLOR_ERASE_MODE:
-          save_version = 2;
+          save_version = MAX (2, save_version);
           break;
 
         default:
           break;
         }
+
+      /* need version 3 for layer trees */
+      if (gimp_viewable_get_children (GIMP_VIEWABLE (layer)))
+        save_version = MAX (3, save_version);
     }
 
+  g_printerr ("%s: version = %d\n", G_STRFUNC, save_version);
+
   info->file_version = save_version;
 }
 
diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c
index 6fe12b8..08bd8ba 100644
--- a/app/xcf/xcf.c
+++ b/app/xcf/xcf.c
@@ -68,7 +68,8 @@ static GimpXcfLoaderFunc * const xcf_loaders[] =
 {
   xcf_load_image,   /* version 0 */
   xcf_load_image,   /* version 1 */
-  xcf_load_image    /* version 2 */
+  xcf_load_image,   /* version 2 */
+  xcf_load_image    /* version 3 */
 };
 
 



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