Fixed non initialized timer causing exception in some rare cases
authorEdouard Tisserant
Thu, 27 Feb 2014 10:45:06 +0100
changeset 1395 bcd1e909076c
parent 1394 d11ca4dd5135
child 1396 bc14b43bd27f
Fixed non initialized timer causing exception in some rare cases
ProjectController.py
--- a/ProjectController.py	Tue Feb 25 13:39:46 2014 +0100
+++ b/ProjectController.py	Thu Feb 27 10:45:06 2014 +0100
@@ -166,12 +166,15 @@
         self.DispatchDebugValuesTimer = None
         
         if frame is not None:
-            frame.LogViewer.SetLogSource(self._connector)
             
             # Timer to pull PLC status
             self.StatusTimer = wx.Timer(self.AppFrame, -1)
             self.AppFrame.Bind(wx.EVT_TIMER, 
                 self.PullPLCStatusProc, self.StatusTimer)
+
+            if self._connector is not None:
+                frame.LogViewer.SetLogSource(self._connector)
+                self.StatusTimer.Start(milliseconds=500, oneShot=False)
             
             # Timer to dispatch debug values to consumers
             self.DispatchDebugValuesTimer = wx.Timer(self.AppFrame, -1)
@@ -1479,7 +1482,8 @@
             self.StatusTimer.Start(milliseconds=500, oneShot=False)
         else:
             # Stop the status Timer
-            self.StatusTimer.Stop()
+            if self.StatusTimer is not None:
+                self.StatusTimer.Stop()
             if update_status:
                 wx.CallAfter(self.UpdateMethodsFromPLCStatus)