babl: properly cache runtime inserted conversions
authorØyvind Kolås <pippin@gimp.org>
Fri, 16 Nov 2018 17:27:32 +0000 (18:27 +0100)
committerØyvind Kolås <pippin@gimp.org>
Fri, 16 Nov 2018 20:32:04 +0000 (21:32 +0100)
The old behavior of avoiding colliding names used in the conversion database
is still used during loading of extension permitting multiple conversions
to be registered for runtime profiling.

babl/babl-conversion.c
babl/babl.c

index a7f7eba2dbeae92af4f370bce33b2b6e14e7f9b7..011765c53b722ca156bf4b0a46306ef0ae884c2b 100644 (file)
@@ -235,7 +235,7 @@ _conversion_new (const char    *name,
         BABL (babl->conversion.destination),
         babl_type_from_id (BABL_DOUBLE));
 
-      {
+      if(0){
         const Babl *fish = babl_conversion_find (src_format, dst_format);
         if (fish)
           return fish;
@@ -284,6 +284,8 @@ create_name (Babl *source, Babl *destination, int type)
 const char *
 babl_conversion_create_name (Babl *source, Babl *destination, int type);
 
+int _babl_loaded = 0;
+
 const char *
 babl_conversion_create_name (Babl *source, Babl *destination, int type)
 {
@@ -292,6 +294,9 @@ babl_conversion_create_name (Babl *source, Babl *destination, int type)
   int id = 0;
   collisions = 0;
   name = create_name (source, destination, type);
+
+  if (!_babl_loaded)
+  {
   babl = babl_db_exist (db, id, name);
   while (babl)
     {
@@ -302,6 +307,7 @@ babl_conversion_create_name (Babl *source, Babl *destination, int type)
       name = create_name (source, destination, type);
       babl = babl_db_exist (db, id, name);
     }
+  }
   return name;
 }
 
index 4479f68619bb7ab8702ab0763dcb675fa40b5574..ef2cfb7d0154402d51618513854f0828bdda3ec5 100644 (file)
@@ -125,6 +125,8 @@ babl_dir_list (void)
   return ret;
 }
 
+extern int _babl_loaded;
+
 void
 babl_init (void)
 {
@@ -133,6 +135,7 @@ babl_init (void)
   if (ref_count++ == 0)
     {
       char * dir_list;
+      _babl_loaded = 0;
 
       babl_internal_init ();
       babl_sampling_class_init ();
@@ -155,6 +158,7 @@ babl_init (void)
       babl_free (dir_list);
 
       babl_init_db ();
+      _babl_loaded = 1;
     }
 }