Commit d3e160a5 authored by Jehan's avatar Jehan
Browse files

babl: re-creation of palette conversions must always set data.

If we allow conversions to be recreated for palettes, it will create a
new identical conversion with collision number incremented in the name
and no user data. Yet the user data is extremely important for palette
conversions, because it contains the palette itself which is required by
the palette conversion functions. Hence we end up crashing.

Moreover, although I think that right now, only palette conversions use
the data field, it might be used for other type of data in the future.
In any case, we should always save this data along as it has been stored
there for a reason.

Finally in babl-palette code, make sure the user data is added to the
models before creating the formats and conversions as we also ended up
in crash-happy code when we didn't.

See: gimp#6501
parent b996a1bb
Pipeline #262399 passed with stage
in 4 minutes and 30 seconds
......@@ -406,6 +406,7 @@ alias_conversion (Babl *babl,
babl_remodel_with_space (
(void*)conv->destination, (void*)space),
"linear", conv->function.linear,
"data", conv->data,
NULL);
break;
case BABL_CONVERSION_PLANAR:
......@@ -415,6 +416,7 @@ alias_conversion (Babl *babl,
babl_remodel_with_space (
(void*)conv->destination, (void*)space),
"planar", conv->function.planar,
"data", conv->data,
NULL);
break;
case BABL_CONVERSION_PLANE:
......@@ -424,6 +426,7 @@ alias_conversion (Babl *babl,
babl_remodel_with_space (
(void*)conv->destination, (void*)space),
"plane", conv->function.plane,
"data", conv->data,
NULL);
break;
default:
......
......@@ -831,6 +831,10 @@ babl_new_palette_with_space (const char *name,
*palptr = default_palette ();;
cname[0] = 'v';
model_no_alpha = babl_model_new ("name", name, component, NULL);
babl_set_user_data (model, palptr);
babl_set_user_data (model_no_alpha, palptr);
cname[0] = '\\';
f_pal_a_u8 = (void*) babl_format_new ("name", name, model, space,
babl_type ("u8"),
......@@ -924,9 +928,6 @@ babl_new_palette_with_space (const char *name,
"data", palptr,
NULL);
babl_set_user_data (model, palptr);
babl_set_user_data (model_no_alpha, palptr);
if (format_u8)
*format_u8 = f_pal_u8;
if (format_u8_with_alpha)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment