Fixed bug when transferring program and a output located variable is forced
authorLaurent Bessard
Thu, 02 May 2013 14:06:24 +0200
changeset 1089 5cd1f8df71aa
parent 1088 43739c16a002
child 1090 f4d08cea7774
Fixed bug when transferring program and a output located variable is forced
IDEFrame.py
ProjectController.py
controls/DebugVariablePanel.py
editors/Viewer.py
graphics/GraphicCommons.py
--- a/IDEFrame.py	Thu May 02 14:00:05 2013 +0200
+++ b/IDEFrame.py	Thu May 02 14:06:24 2013 +0200
@@ -1970,7 +1970,7 @@
                     elif isinstance(editor, GraphicViewer):
                         editor.ResetView(True)
                     else:
-                        editor.RefreshView()
+                        editor.RegisterVariables()
                 elif editor.IsDebugging():
                     editor.RegisterVariables()
             self.DebugVariablePanel.UnregisterObsoleteData()
--- a/ProjectController.py	Thu May 02 14:00:05 2013 +0200
+++ b/ProjectController.py	Thu May 02 14:06:24 2013 +0200
@@ -1185,12 +1185,16 @@
     def ReArmDebugRegisterTimer(self):
         if self.DebugTimer is not None:
             self.DebugTimer.cancel()
-
-        # Timer to prevent rapid-fire when registering many variables
-        # use wx.CallAfter use keep using same thread. TODO : use wx.Timer instead
-        self.DebugTimer=Timer(0.5,wx.CallAfter,args = [self.RegisterDebugVarToConnector])
-        # Rearm anti-rapid-fire timer
-        self.DebugTimer.start()
+        
+        # Prevent to call RegisterDebugVarToConnector when PLC is not started
+        # If an output location var is forced it's leads to segmentation fault in runtime
+        # Links between PLC located variables and real variables are not ready
+        if self.previous_plcstate == "Started":
+            # Timer to prevent rapid-fire when registering many variables
+            # use wx.CallAfter use keep using same thread. TODO : use wx.Timer instead
+            self.DebugTimer=Timer(0.5,wx.CallAfter,args = [self.RegisterDebugVarToConnector])
+            # Rearm anti-rapid-fire timer
+            self.DebugTimer.start()
 
     def GetDebugIECVariableType(self, IECPath):
         Idx, IEC_Type = self._IECPathToIdx.get(IECPath,(None,None))
@@ -1235,7 +1239,7 @@
 
     def UnsubscribeAllDebugIECVariable(self):
         self.IECdebug_lock.acquire()
-        IECdebug_data = {}
+        self.IECdebug_datas = {}
         self.IECdebug_lock.release()
 
         self.ReArmDebugRegisterTimer()
--- a/controls/DebugVariablePanel.py	Thu May 02 14:00:05 2013 +0200
+++ b/controls/DebugVariablePanel.py	Thu May 02 14:06:24 2013 +0200
@@ -1810,6 +1810,7 @@
             self.Thaw()
         
     def UnregisterObsoleteData(self):
+        self.RegisterVariables()
         if USE_MPL:
             if self.DataProducer is not None:
                 self.Ticktime = self.DataProducer.GetTicktime()
--- a/editors/Viewer.py	Thu May 02 14:00:05 2013 +0200
+++ b/editors/Viewer.py	Thu May 02 14:06:24 2013 +0200
@@ -1041,7 +1041,11 @@
             self.RefreshRect(self.GetScrolledRect(refresh_rect), False)
         else:
             DebugViewer.RefreshNewData(self)
-        
+    
+    def RegisterVariables(self):
+        DebugViewer.RegisterVariables(self)
+        self.RefreshView()
+    
     # Refresh Viewer elements
     def RefreshView(self, variablepanel=True, selection=None):
         EditorPanel.RefreshView(self, variablepanel)
--- a/graphics/GraphicCommons.py	Thu May 02 14:00:05 2013 +0200
+++ b/graphics/GraphicCommons.py	Thu May 02 14:06:24 2013 +0200
@@ -327,7 +327,7 @@
             if producer is not None:
                 producer.SubscribeDebugIECVariable("__tick__", self)
             if self.DataProducer is not None:
-                self.DataProducer.UnsubscribeDebugIECVariable("__tick__", self)        
+                self.DataProducer.UnsubscribeDebugIECVariable("__tick__", self)
         self.DataProducer = producer
     
     def IsDebugging(self):
@@ -353,7 +353,8 @@
             self.DataProducer.UnsubscribeDebugIECVariable(iec_path, consumer)
     
     def RegisterVariables(self):
-        pass
+        if self.RegisterTick and self.Debug and self.DataProducer is not None:
+            self.DataProducer.SubscribeDebugIECVariable("__tick__", self)
     
     def GetDataType(self, iec_path):
         if self.DataProducer is not None: