Revert "libgimpwidgets: fix #11339 chroma slider fail on small increments"

This reverts commit bdddc94151.

This commit was not fixing the issue the proper way and was creating new
issues.

The real problem was that for very small increments at a time, a color
change could be perceptually identical to the previous color and
therefore not trigger color updates down to subclasses.
The reverted commit was trying to work around this by not updating the
GimpColorSelector color when it was perceptually identical (therefore
next check may be a bigger color distance), but this was definitely not
right. It was creating inconsistency in the stored color with the
actually selected one and that was the root for more issues.

See the next commit for a proper fix.

Oh and by the way, there was no leak, unlike what the reverted commit
message was saying. The old color was freed. ;-)
This commit is contained in:
Jehan 2024-10-09 21:26:06 +02:00
parent abf0c1c272
commit 079a68a920
1 changed files with 10 additions and 20 deletions

View File

@ -400,44 +400,34 @@ gimp_color_selector_get_show_alpha (GimpColorSelector *selector)
* @color: The new color.
*
* Sets the color shown in the @selector widget.
*
* Unlike most setters, this does NOT change the model (or update views)
* when the change is not perceivable to the eye.
*
* A control cannot depend on this actually changing the model.
* A control, e.g. a chroma slider, may show a small difference from the model.
*/
**/
void
gimp_color_selector_set_color (GimpColorSelector *selector,
GeglColor *color)
{
GimpColorSelectorClass *selector_class;
GimpColorSelectorPrivate *priv;
GeglColor *old_color;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
g_return_if_fail (GEGL_IS_COLOR (color));
priv = gimp_color_selector_get_instance_private (selector);
if (! gimp_color_is_perceptually_identical (priv->color, color))
{
g_object_unref (priv->color);
priv->color = gegl_color_duplicate (color);
old_color = priv->color;
priv->color = gegl_color_duplicate (color);
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
{
if (selector_class->set_color)
selector_class->set_color (selector, priv->color);
gimp_color_selector_emit_color_changed (selector);
}
else
{
/* This happens often, more than you might expect.
* A single user event may yield many calls to the setter,
* some but not all of which are perceptually identical.
*/
g_debug ("%s new color perceptually identical", G_STRFUNC);
}
g_object_unref (old_color);
}
/**