From 53e8a1dabe21cecd5638b33eeff54fbfc5fe4673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 17 Mar 2014 18:54:47 +0100 Subject: [PATCH] Test if exposed before using computed values in motion In some cases, motion event is triggered before expose. So motion method should take care of such case. issue3755 review4301002 --- tryton/gui/window/view_form/view/graph_gtk/bar.py | 3 +++ tryton/gui/window/view_form/view/graph_gtk/line.py | 3 +++ tryton/gui/window/view_form/view/graph_gtk/pie.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/tryton/gui/window/view_form/view/graph_gtk/bar.py b/tryton/gui/window/view_form/view/graph_gtk/bar.py index 8abebb5bee..0d99af6557 100644 --- a/tryton/gui/window/view_form/view/graph_gtk/bar.py +++ b/tryton/gui/window/view_form/view/graph_gtk/bar.py @@ -65,6 +65,9 @@ class Bar(Graph): def motion(self, widget, event): super(Bar, self).motion(widget, event) + if not getattr(self, 'area', None): + return + def intersect(bar, event): x = self.area.w * bar.x + self.area.x y = self.area.h * bar.y + self.area.y diff --git a/tryton/gui/window/view_form/view/graph_gtk/line.py b/tryton/gui/window/view_form/view/graph_gtk/line.py index bd05f53bf9..13868f4323 100644 --- a/tryton/gui/window/view_form/view/graph_gtk/line.py +++ b/tryton/gui/window/view_form/view/graph_gtk/line.py @@ -154,6 +154,9 @@ class Line(Graph): cr.restore() def motion(self, widget, event): + if not getattr(self, 'area', None): + return + nearest = None for point in self.points: x = point.x * self.area.w + self.area.x diff --git a/tryton/gui/window/view_form/view/graph_gtk/pie.py b/tryton/gui/window/view_form/view/graph_gtk/pie.py index 174ebf547b..9018288c3d 100644 --- a/tryton/gui/window/view_form/view/graph_gtk/pie.py +++ b/tryton/gui/window/view_form/view/graph_gtk/pie.py @@ -108,6 +108,9 @@ class Pie(Graph): def motion(self, widget, event): super(Pie, self).motion(widget, event) + if not getattr(self, 'area', None): + return + d = (event.x - self.centerx) ** 2 + (event.y - self.centery) ** 2 if d > self.radius ** 2: self.popup.hide()