From d60eaa7b449c8629c51a968f34dc9b61d856ee8a Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Fri, 18 Mar 2016 09:04:35 +0100 Subject: [PATCH] scanwidget: fix div by zero rubberband width (closes #335) (4b8fe1e) --- artiq/gui/scanwidget.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/artiq/gui/scanwidget.py b/artiq/gui/scanwidget.py index 5c2a76938..f2562b450 100644 --- a/artiq/gui/scanwidget.py +++ b/artiq/gui/scanwidget.py @@ -159,10 +159,13 @@ class ScanWidget(QtWidgets.QWidget): if self._drag == "zoom": self._rubber.hide() left, scale = self._axisView - scale *= self.width()/self._rubber.geometry().width() center = self._pixelToAxis(self._rubber.geometry().center().x()) - if center: - scale = min(scale, self.dynamicRange/abs(center)) + if self._rubber.geometry().width(): + scale *= self.width()/self._rubber.geometry().width() + if center: + scale = min(scale, self.dynamicRange/abs(center)) + elif center: + scale = self.dynamicRange/abs(center) left = self.width()/2 - center*scale self._setView(left, scale) self._drag = None