Bug while closing GraphicViewer and PLC running generating errors fixed
authorlbessard
Thu, 09 Apr 2009 15:40:27 +0200
changeset 344 0acc2bd658f0
parent 343 dc8ff76b39fd
child 345 d79f73a337d7
Bug while closing GraphicViewer and PLC running generating errors fixed
GraphicViewer.py
--- a/GraphicViewer.py	Thu Apr 09 15:39:45 2009 +0200
+++ b/GraphicViewer.py	Thu Apr 09 15:40:27 2009 +0200
@@ -206,12 +206,15 @@
         pass
     
     def AddPoint(self, tick, value):
-        self.Datas.append((float(tick), {True:1., False:0.}.get(value, float(value))))
-        if self.CurrentValue + self.CurrentRange == len(self.Datas) - 1:
-            self.CurrentValue += 1
-            self.RefreshView()
-        elif len(self.Datas) < self.CurrentValue + self.CurrentRange:
-            self.RefreshView()
+        if self:
+            self.Datas.append((float(tick), {True:1., False:0.}.get(value, float(value))))
+            if self.CurrentValue + self.CurrentRange == len(self.Datas) - 1:
+                self.CurrentValue += 1
+                self.RefreshView()
+            elif len(self.Datas) < self.CurrentValue + self.CurrentRange:
+                self.RefreshView()
+            else:
+                self.RefreshScrollBar()
             
     def RefreshScrollBar(self):
         self.CanvasPosition.SetScrollbar(self.CurrentValue, self.CurrentRange, len(self.Datas), self.CurrentRange)