From 6c1c497ce09c9d79d5a9d83a0164e5b9ec83da0a Mon Sep 17 00:00:00 2001 From: Jehan Date: Sun, 31 Aug 2025 17:42:51 +0200 Subject: [PATCH] libgimpwidgets: fix build warning. This fixes the following warning when compiling with CLang: > libgimpwidgets/gimppropwidgets.c:3961:11: warning: variable 'unit_type' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] > 3961 | if (pspec_unit && GIMP_IS_PARAM_SPEC_UNIT (pspec_unit)) If a unit property name is set, it must be a valid unit property. Let's check, output a CRITICAL and return NULL otherwise. --- libgimpwidgets/gimppropwidgets.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c index d4453ec872..753807ad8b 100644 --- a/libgimpwidgets/gimppropwidgets.c +++ b/libgimpwidgets/gimppropwidgets.c @@ -3929,6 +3929,9 @@ static void gimp_prop_coordinates_notify_unit (GObject *config, * properties, which will usually represent X and Y coordinates, and * their associated unit property. * + * If @unit_format is %NULL, the unit will default to inch. Otherwise it + * must be the name of a property of type %GimpParamUnit: + * * Returns: (transfer full): A new #GimpSizeEntry widget. * * Since: 2.4 @@ -3955,19 +3958,18 @@ gimp_prop_coordinates_new (GObject *config, { GParamSpec *pspec_unit = NULL; - pspec_unit = g_object_class_find_property (G_OBJECT_GET_CLASS (config), - unit_property_name); + pspec_unit = check_param_spec_w (config, unit_property_name, + GIMP_TYPE_PARAM_UNIT, G_STRFUNC); - if (pspec_unit && GIMP_IS_PARAM_SPEC_UNIT (pspec_unit)) - { - show_pixels = gimp_param_spec_unit_pixel_allowed (pspec_unit); - show_percents = gimp_param_spec_unit_percent_allowed (pspec_unit); + g_return_val_if_fail (pspec_unit != NULL, NULL); - if (show_pixels) - show_resolution = FALSE; + show_pixels = gimp_param_spec_unit_pixel_allowed (pspec_unit); + show_percents = gimp_param_spec_unit_percent_allowed (pspec_unit); - g_object_get (config, unit_property_name, &unit_type, NULL); - } + if (show_pixels) + show_resolution = FALSE; + + g_object_get (config, unit_property_name, &unit_type, NULL); } else {