[babl/wip/Jehan/gimp-bug-6501: 3/3] babl: re-creation of palette conversions must always set data.
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl/wip/Jehan/gimp-bug-6501: 3/3] babl: re-creation of palette conversions must always set data.
- Date: Sat, 15 May 2021 20:57:05 +0000 (UTC)
commit 69e6b09067f2bbca7ac0dfda0131042d7d1f448c
Author: Jehan <jehan girinstud io>
Date: Wed Mar 3 11:03:38 2021 +0100
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: https://gitlab.gnome.org/GNOME/gimp/-/issues/6501
babl/babl-fish-path.c | 3 +++
babl/babl-palette.c | 7 ++++---
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index b0396dbcb..32da078e9 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -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:
diff --git a/babl/babl-palette.c b/babl/babl-palette.c
index 086da675d..1db8facd9 100644
--- a/babl/babl-palette.c
+++ b/babl/babl-palette.c
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]