From 0e411226806c9afe0b9fde6368b94849204ad907 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 11 May 2013 00:07:18 +0200 Subject: [PATCH] WINGs: Changed equality comparison on floating point number The equality comparison (a == b) is known to be a dangerous trap when floating-point arithmetics are involved. This patch changes all the cases which try to do this to a safer check. --- WINGs/wscrollview.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/WINGs/wscrollview.c b/WINGs/wscrollview.c index 8b33812e..ae3daaec 100644 --- a/WINGs/wscrollview.c +++ b/WINGs/wscrollview.c @@ -503,10 +503,10 @@ static void updateScrollerProportion(ScrollView * sPtr) prop = (float)sPtr->viewport->size.width / (float)sPtr->contentView->size.width; - if (oldP == 1.0) - value = 0; - else + if (oldP < 1.0) value = (prop * oldV) / oldP; + else + value = 0; WMSetScrollerParameters(sPtr->hScroller, value, prop); } if (sPtr->flags.hasVScroller) { @@ -515,10 +515,10 @@ static void updateScrollerProportion(ScrollView * sPtr) prop = (float)sPtr->viewport->size.height / (float)sPtr->contentView->size.height; - if (oldP == 1.0) - value = 0; - else + if (oldP < 1.0) value = (prop * oldV) / oldP; + else + value = 0; WMSetScrollerParameters(sPtr->vScroller, value, prop); } applyScrollerValues(sPtr); -- 2.11.4.GIT