Browse code

Avoid division by zero.

From: Marius Gedminas <marius@gedmin.as>

Jose.R.Fonseca authored on 13/07/2008 03:21:32
Showing 1 changed files

  • xdot.py index b8bbc55..278f7cd 100755
... ...
@@ -678,8 +678,9 @@ class ZoomToAnimation(MoveToAnimation):
678 678
         rect = self.dot_widget.get_allocation()
679 679
         visible = min(rect.width, rect.height) / self.dot_widget.zoom_ratio
680 680
         visible *= 0.9
681
-        desired_middle_zoom = visible / distance
682
-        self.extra_zoom = min(0, 4 * (desired_middle_zoom - middle_zoom))
681
+        if distance > 0:
682
+            desired_middle_zoom = visible / distance
683
+            self.extra_zoom = min(0, 4 * (desired_middle_zoom - middle_zoom))
683 684
 
684 685
     def animate(self, t):
685 686
         a, b, c = self.source_zoom, self.extra_zoom, self.target_zoom