summaryrefslogtreecommitdiff
path: root/babl/babl-model.c
diff options
context:
space:
mode:
authorRupert Weber <gimp@leguanease.org>2010-10-01 02:18:53 +0200
committerØyvind Kolås <pippin@gimp.org>2011-01-20 21:42:59 +0000
commit4006f433f9e0d6b3cb54943adccada464f69595a (patch)
treea3d86e3b9b60841a7df3d7a135414e2c5ae04fd8 /babl/babl-model.c
parentcfeaaf62b8d5babef2ab34798fff1e1f64905422 (diff)
allow reregistering but check for differences
babl_model_new() emitted a warning when reregistering a model, babl_format_new(), babl_type_new(), and babl_component_new() quietly returned a preexisting object. Changed so that all four functions return the preexisting object if the new registration doesn't conflict, otherwise make the error fatal. (Fixed some conflicting and redundant registrations for "Y'CbCr u8" along the way)
Diffstat (limited to 'babl/babl-model.c')
-rw-r--r--babl/babl-model.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/babl/babl-model.c b/babl/babl-model.c
index 4766b3b..11a3dd1 100644
--- a/babl/babl-model.c
+++ b/babl/babl-model.c
@@ -74,6 +74,24 @@ model_new (const char *name,
return babl;
}
+static int
+is_model_duplicate (Babl *babl, int components, BablComponent **component)
+{
+ int i;
+
+ if (babl->model.components != components)
+ return 0;
+
+ for (i = 0; i < components; i++)
+ {
+ if (babl->model.component[i] != component[i])
+ return 0;
+ }
+
+ return 1;
+}
+
+
Babl *
babl_model_new (void *first_argument,
...)
@@ -166,6 +184,8 @@ babl_model_new (void *first_argument,
name = babl_model_create_name (components, component);
babl = babl_db_exist (db, id, name);
+ if (id && !babl && babl_db_exist (db, 0, name))
+ babl_fatal ("Trying to reregister BablModel '%s' with different id!", name);
if (! babl)
{
@@ -175,7 +195,9 @@ babl_model_new (void *first_argument,
}
else
{
- babl_log ("Warning: BablModel '%s' already registered!", name);
+ if (!is_model_duplicate (babl, components, component))
+ babl_fatal ("BablModel '%s' already registered "
+ "with different components!", name);
}
babl_free (name);