Issue #14972: Fix GimpLabelSpin CRITICAL warnings for small double ranges

During instantiation, the widget bypassed saving the PROP_DIGITS state
because the spinbutton was not populated, leaving digits at 0. This
forced the widget into an integer state, causing step calculations to
break for small fractional ranges (e.g., 0.001 to 1.0).

Added G_PARAM_CONSTRUCT to the digits property and moved the internal
assignment outside the spinbutton check so the correct initial state
is saved immediately.

Added a check to ensure step and page do not go out of range.
This commit is contained in:
kaushik_B 2026-02-22 14:07:40 +05:30 committed by Jehan
parent b7d89728c4
commit ca931fbe33

View file

@ -167,7 +167,8 @@ gimp_label_spin_class_init (GimpLabelSpinClass *klass)
g_param_spec_int ("digits", NULL, g_param_spec_int ("digits", NULL,
"The number of decimal places to display", "The number of decimal places to display",
-1, G_MAXINT, -1, -1, G_MAXINT, -1,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
} }
static void static void
@ -241,9 +242,9 @@ gimp_label_spin_set_property (GObject *object,
} }
break; break;
case PROP_DIGITS: case PROP_DIGITS:
priv->digits = g_value_get_int (value);
if (priv->spinbutton) if (priv->spinbutton)
{ {
priv->digits = g_value_get_int (value);
gimp_label_spin_update_settings (spin); gimp_label_spin_update_settings (spin);
} }
break; break;
@ -356,7 +357,9 @@ gimp_label_spin_update_settings (GimpLabelSpin *spin)
if (adjust_step && digits == 0 && step < 1.0) if (adjust_step && digits == 0 && step < 1.0)
{ {
step = 1.0; step = 1.0;
if (page < step) if (step > upper-lower)
step = upper-lower;
if (page < step || page > upper-lower)
page = step; page = step;
} }