From 2b7e98f4b3d48269dbfb2232af80cde92bcae306 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 6 Jun 2009 11:37:18 -0400 Subject: [PATCH] Be more tolerant about natural_width < min_width Due to the accumulation of floating point errors, natural_width and min_width can diverge significantly even if the math for computing them is correct. So just clamp natural_width to min_width instead of warning about it. http://bugzilla.openedhand.com/show_bug.cgi?id=1632 Signed-off-by: Emmanuele Bassi --- clutter/clutter-actor.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 5257b746e..775137d6f 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -4464,8 +4464,6 @@ clutter_actor_get_preferred_size (ClutterActor *self, *natural_height_p = natural_height; } -#define FLOAT_EPSILON (1e-4) /* 1/1000 pixel is the precision used */ - /** * clutter_actor_get_preferred_width: * @self: A #ClutterActor @@ -4513,14 +4511,11 @@ clutter_actor_get_preferred_width (ClutterActor *self, &min_width, &natural_width); - if (natural_width < min_width - FLOAT_EPSILON) - { - g_warning ("Actor of type %s reported a natural width " - "of %.2f px lower than min width %.2f px", - G_OBJECT_TYPE_NAME (self), - natural_width, - min_width); - } + /* Due to accumulated float errors, it's better not to warn + * on this, but just fix it. + */ + if (natural_width < min_width) + natural_width = min_width; if (!priv->min_width_set) priv->request_min_width = min_width; @@ -4585,14 +4580,11 @@ clutter_actor_get_preferred_height (ClutterActor *self, &min_height, &natural_height); - if (natural_height < min_height - FLOAT_EPSILON) - { - g_warning ("Actor of type %s reported a natural height " - "of %.2f px lower than min height %.2f px", - G_OBJECT_TYPE_NAME (self), - natural_height, - min_height); - } + /* Due to accumulated float errors, it's better not to warn + * on this, but just fix it. + */ + if (natural_height < min_height) + natural_height = min_height; if (!priv->min_height_set) priv->request_min_height = min_height;