From: Christophe CURIS <[email protected]>

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 8b33812..ae3daae 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);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to