From 2bf815131af32b8c5239425b8dacbacf29d503cf Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 17 Dec 2008 19:26:24 +0000 Subject: [PATCH] [clutter-interval] Fix calculation of interval for unsigned types The patch makes it cast to double before subtracting the original value from the target value. Otherwise if the target value is less than the original value then the subtraction will overflow and the factor will be multiplied by a very large number instead of the desired interval. The problem is demonstrable using the border-width property of ClutterRectangle. --- clutter/clutter-interval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-interval.c b/clutter/clutter-interval.c index f8d6c4aa6..5f2924d09 100644 --- a/clutter/clutter-interval.c +++ b/clutter/clutter-interval.c @@ -206,7 +206,7 @@ clutter_interval_real_compute_value (ClutterInterval *interval, ia = g_value_get_uint (initial); ib = g_value_get_uint (final); - res = (factor * (ib - ia)) + ia; + res = (factor * (ib - (gdouble) ia)) + ia; g_value_set_uint (value, res); } @@ -219,7 +219,7 @@ clutter_interval_real_compute_value (ClutterInterval *interval, ia = g_value_get_uchar (initial); ib = g_value_get_uchar (final); - res = (factor * (ib - ia)) + ia; + res = (factor * (ib - (gdouble) ia)) + ia; g_value_set_uchar (value, res); }