Browse code

Constrain zoom ratio to a sane range to prevent numeric instability (issue #13).

José Fonseca authored on 09/05/2013 08:31:26
Showing 1 changed files

  • xdot.py index a6c7cd5..904ef74 100755
... ...
@@ -1554,6 +1554,10 @@ class DotWidget(gtk.DrawingArea):
1554 1554
             self.queue_draw()
1555 1555
 
1556 1556
     def zoom_image(self, zoom_ratio, center=False, pos=None):
1557
+        # Constrain zoom ratio to a sane range to prevent numeric instability.
1558
+        zoom_ratio = min(zoom_ratio, 1E4)
1559
+        zoom_ratio = max(zoom_ratio, 1E-6)
1560
+
1557 1561
         if center:
1558 1562
             self.x = self.graph.width/2
1559 1563
             self.y = self.graph.height/2