Adding tests to avoid in DataConsumer to call DataProducer if not defined
authorlaurent
Thu, 08 Oct 2009 16:39:08 +0200
changeset 442 a756b58699b8
parent 441 b7511a0b261c
child 443 5f7d5d1a6f99
Adding tests to avoid in DataConsumer to call DataProducer if not defined
graphics/GraphicCommons.py
--- a/graphics/GraphicCommons.py	Tue Oct 06 09:26:05 2009 +0200
+++ b/graphics/GraphicCommons.py	Thu Oct 08 16:39:08 2009 +0200
@@ -247,6 +247,8 @@
             consumer.Inhibit(inhibit)
     
     def AddDataConsumer(self, iec_path, consumer):
+        if self.DataProducer is None:
+            return False
         result = self.DataProducer.SubscribeDebugIECVariable(iec_path, consumer) is not None
         if result is not None and consumer != self:
             self.DataConsumers[consumer] = iec_path
@@ -258,8 +260,9 @@
             self.DataProducer.UnsubscribeDebugIECVariable(iec_path, consumer)
     
     def DeleteDataConsumers(self):
-        for consumer, iec_path in self.DataConsumers.iteritems():
-            self.DataProducer.UnsubscribeDebugIECVariable(iec_path, consumer)
+        if self.DataProducer is not None:
+            for consumer, iec_path in self.DataConsumers.iteritems():
+                self.DataProducer.UnsubscribeDebugIECVariable(iec_path, consumer)
         self.DataConsumers = {}
     
     def OnRefreshTimer(self, event):