[gimp] app: fix the questionable while loop in another place



commit ac11569830f3dfcd20f4310b8000781b652e26fc
Author: Sven Neumann <sven gimp org>
Date:   Fri May 29 23:33:54 2009 +0200

    app: fix the questionable while loop in another place
    
    The questionable while loops to get GimpCoords.direction into a proper
    range were used in two places. This commit fixes the actual problematic
    place where, under some rare circumstances, the code used to go into a
    loop for a very long time.
---
 app/display/gimpdisplayshell-coords.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/app/display/gimpdisplayshell-coords.c b/app/display/gimpdisplayshell-coords.c
index cf1e8f9..9b4e787 100644
--- a/app/display/gimpdisplayshell-coords.c
+++ b/app/display/gimpdisplayshell-coords.c
@@ -332,11 +332,7 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
             coords->direction = coords->direction + 0.5;
         }
 
-      while (coords->direction > 1.0)
-        coords->direction -= 1.0;
-
-      while (coords->direction < 0.0)
-        coords->direction += 1.0;
+      coords->direction = coords->direction - floor (coords->direction);
 
       delta_dir = coords->direction - shell->last_coords.direction;
 
@@ -356,7 +352,7 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
                                0.5 * shell->last_coords.direction);
         }
 
-      coords->direction = coords->direction - floor(coords->direction);
+      coords->direction = coords->direction - floor (coords->direction);
 
       /* High speed -> less smooth*/
       inertia_factor *= (1 - coords->velocity);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]