babl: fix bug in caching of CMYK profiles
authorØyvind Kolås <pippin@gimp.org>
Mon, 30 Nov 2020 04:11:18 +0000 (05:11 +0100)
committerØyvind Kolås <pippin@gimp.org>
Mon, 30 Nov 2020 04:11:25 +0000 (05:11 +0100)
The check for duplicates was gumming up the CMYK profile initialization,
causing babl internal CMYK to be used instead and the original icc
profile to be lost.

babl/babl-icc.c
babl/babl-space.c

index 7d1fd6705103eb2ae58f0ad74d1768587939f014..a0327463d158523f20a49f36cd88028077e2b3ae 100644 (file)
@@ -967,6 +967,8 @@ babl_space_from_icc (const char   *icc_data,
     if (!strcmp (color_space.str, "CMYK"))
     {
        ret = _babl_space_for_lcms (icc_data, icc_length);
+       if (!ret)
+         return NULL;
        if (ret->space.icc_type == BablICCTypeCMYK)
          return ret;
        ret->space.icc_length = icc_length;
@@ -1002,12 +1004,10 @@ babl_space_from_icc (const char   *icc_data,
                                                     //  INTENT_PERCEPTUAL,0);//intent & 7, 0);
        cmsCloseProfile (ret->space.cmyk.lcms_profile); // XXX keep it open in case of CMYK to CMYK transforms needed?
 #endif
+       ret->space.icc_type = BablICCTypeCMYK;
        return ret;
     }
 
-
-
-
     if (strcmp (color_space.str, "RGB ")
         && strcmp (color_space.str, "GRAY")
     )
index c662629713625ac6cf426bf17e9820cde7f5c2bd..282d728f74b44560dd58011159586296de584eb8 100644 (file)
@@ -244,7 +244,6 @@ _babl_space_for_lcms (const char *icc_data,
   memset (&space, 0, sizeof(space));
   space.instance.class_type = BABL_SPACE;
   space.instance.id         = 0;
-  space.icc_type = BablICCTypeCMYK;
 
   if (i >= MAX_SPACES-1)
   {