From 2baa518a3018183f9260ea501815541dce4a822c Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Thu, 6 Apr 2023 04:10:52 +0000 Subject: [PATCH] libgimpwidgets: Don't call scaled digits on pixels Adds a check to cast resolution to an int if units are pixels, rather than calling gimp_unit_get_scaled_digits(). This prevents a LibGimp-CRITICAL about "_gimp_unit_cache_get_digits: assertion 'unit >= GIMP_UNIT_INCH' failed" --- libgimpwidgets/gimppropwidgets.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c index 17bd390e25..d4c842bf9b 100644 --- a/libgimpwidgets/gimppropwidgets.c +++ b/libgimpwidgets/gimppropwidgets.c @@ -3236,6 +3236,7 @@ gimp_prop_size_entry_new (GObject *config, gdouble lower; gdouble upper; GimpUnit unit_value; + gint scaled_resolution; param_spec = find_param_spec (config, property_name, G_STRFUNC); if (! param_spec) @@ -3278,11 +3279,15 @@ gimp_prop_size_entry_new (GObject *config, show_percent = FALSE; } + if (unit_value != GIMP_UNIT_PIXEL) + scaled_resolution = gimp_unit_get_scaled_digits (unit_value, resolution); + else + scaled_resolution = (gint) resolution; + entry = gimp_size_entry_new (1, unit_value, unit_format, show_pixels, show_percent, FALSE, gimp_prop_size_entry_num_chars (lower, upper) + 1 + - gimp_unit_get_scaled_digits (unit_value, resolution), - update_policy); + scaled_resolution, update_policy); set_param_spec (NULL, gimp_size_entry_get_help_widget (GIMP_SIZE_ENTRY (entry), 0),