Fixed crash (segfault) when logging debug messages
authorEdouard Tisserant
Tue, 05 Feb 2013 23:28:35 +1100
changeset 923 6ef6e0b3a908
parent 922 60fafd828a30
child 926 2323981f5d41
Fixed crash (segfault) when logging debug messages
ProjectController.py
connectors/PYRO/__init__.py
targets/plc_debug.c
--- a/ProjectController.py	Sun Feb 03 16:21:56 2013 +1100
+++ b/ProjectController.py	Tue Feb 05 23:28:35 2013 +1100
@@ -1110,8 +1110,10 @@
     def UpdateMethodsFromPLCStatus(self):
         status = None
         if self._connector is not None:
-            status, log_count = self._connector.GetPLCstatus()
-            self.UpdatePLCLog(log_count)
+            PLCstatus = self._connector.GetPLCstatus()
+            if PLCstatus is not None:
+                status, log_count = PLCstatus
+                self.UpdatePLCLog(log_count)
         if status is None:
             self._connector = None
             status = "Disconnected"
--- a/connectors/PYRO/__init__.py	Sun Feb 03 16:21:56 2013 +1100
+++ b/connectors/PYRO/__init__.py	Tue Feb 05 23:28:35 2013 +1100
@@ -88,7 +88,7 @@
 
     # Check connection is effective. 
     # lambda is for getattr of GetPLCstatus to happen inside catcher
-    if PyroCatcher(lambda:RemotePLCObjectProxy.GetPLCstatus())() == None:
+    if PyroCatcher(lambda:RemotePLCObjectProxy.GetPLCstatus())() is None:
         confnodesroot.logger.write_error(_("Cannot get PLC status - connection failed.\n"))
         return None
 
@@ -144,7 +144,7 @@
 
         def _PyroGetPLCstatus(self):
             return RemotePLCObjectProxy.GetPLCstatus()
-        GetPLCstatus = PyroCatcher(_PyroGetPLCstatus, ("Broken",-1))
+        GetPLCstatus = PyroCatcher(_PyroGetPLCstatus, ("Broken",None))
 
         def _PyroRemoteExec(self, script, **kwargs):
             return RemotePLCObjectProxy.RemoteExec(script, **kwargs)
--- a/targets/plc_debug.c	Sun Feb 03 16:21:56 2013 +1100
+++ b/targets/plc_debug.c	Tue Feb 05 23:28:35 2013 +1100
@@ -310,7 +310,7 @@
 #define LOG_CRITICAL 0
 #define LOG_WARNING 1
 #define LOG_INFO 2
-#define LOG_DEBUG 4
+#define LOG_DEBUG 3
 
 #define LOG_BUFFER_SIZE (1<<14) /*16Ko*/
 #define LOG_BUFFER_MASK (LOG_BUFFER_SIZE-1)