From a7637bfb4a7d943e540371eb68f4fa97a36bc6b6 Mon Sep 17 00:00:00 2001 From: Jehan Date: Mon, 12 Feb 2024 19:26:04 +0100 Subject: [PATCH] libgimpconfig: special-case GeglColor param comparison if one is NULL. The current values_cmp() method will segfault if an object contains a NULL GeglColor value. I fixed it in commit c0477bcb0 in GEGL, but since the GEGL release is already done, I add this special-casing on GIMP side. To be removed when we release and depend on GEGL 0.4.50. The crash was happening when activating the text tool and raised in a comment of another report: https://gitlab.gnome.org/GNOME/gimp/-/issues/10813#note_2009702 --- libgimpconfig/gimpconfig-utils.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libgimpconfig/gimpconfig-utils.c b/libgimpconfig/gimpconfig-utils.c index 5b5f11ea8f..a7fd886c9a 100644 --- a/libgimpconfig/gimpconfig-utils.c +++ b/libgimpconfig/gimpconfig-utils.c @@ -57,7 +57,17 @@ gimp_config_diff_property (GObject *a, g_object_get_property (a, prop_spec->name, &a_value); g_object_get_property (b, prop_spec->name, &b_value); - if (g_param_values_cmp (prop_spec, &a_value, &b_value)) + /* TODO: temporary hack to handle case of NULL GeglColor in a param value. + * This got fixed in commit c0477bcb0 which should be available for GEGL + * 0.4.50. In the meantime, this will do. + */ + if (GEGL_IS_PARAM_SPEC_COLOR (prop_spec) && + (! g_value_get_object (&a_value) || + ! g_value_get_object (&b_value))) + { + retval = (g_value_get_object (&a_value) != g_value_get_object (&b_value)); + } + else if (g_param_values_cmp (prop_spec, &a_value, &b_value)) { if ((prop_spec->flags & GIMP_CONFIG_PARAM_AGGREGATE) && G_IS_PARAM_SPEC_OBJECT (prop_spec) &&