Fix bug debug viewers are block when a Graphic Viewer in debug mode is hidden
authorLaurent Bessard
Mon, 05 Nov 2012 20:16:45 +0100
changeset 877 7e695249be8d
parent 876 179d5c455f29
child 878 37256069baed
Fix bug debug viewers are block when a Graphic Viewer in debug mode is hidden
graphics/GraphicCommons.py
--- a/graphics/GraphicCommons.py	Mon Nov 05 20:15:28 2012 +0100
+++ b/graphics/GraphicCommons.py	Mon Nov 05 20:16:45 2012 +0100
@@ -308,6 +308,7 @@
         self.LastRefreshTime = gettime()
         self.HasAcquiredLock = False
         self.AccessLock = Lock()
+        self.TimerAccessLock = Lock()
         
         self.LastRefreshTimer = None
         
@@ -316,7 +317,8 @@
     def __del__(self):
         self.DataProducer = None
         self.DeleteDataConsumers()
-        self.RefreshTimer.Stop()
+        if self.LastRefreshTimer is not None:
+            self.LastRefreshTimer.Stop()
     
     def SetDataProducer(self, producer):
         if self.RegisterTick and self.Debug:
@@ -374,13 +376,17 @@
             self.AccessLock.release()
             self.RefreshNewData()
         else:
+            self.TimerAccessLock.acquire()
             self.LastRefreshTimer = Timer(REFRESH_PERIOD, self.ShouldRefresh)
             self.LastRefreshTimer.start()
+            self.TimerAccessLock.release()
     
     def NewDataAvailable(self, *args, **kwargs):
+        self.TimerAccessLock.acquire()
         if self.LastRefreshTimer is not None:
             self.LastRefreshTimer.cancel()
             self.LastRefreshTimer=None
+        self.TimerAccessLock.release()
         if not self.Inhibited:
             current_time = gettime()
             if current_time - self.LastRefreshTime > REFRESH_PERIOD and DEBUG_REFRESH_LOCK.acquire(False):
@@ -390,12 +396,16 @@
                 self.LastRefreshTime = gettime()
                 self.Inhibit(True)
                 wx.CallAfter(self.RefreshViewOnNewData, *args, **kwargs)
+        elif not self.IsShown() and self.HasAcquiredLock:
+            DebugViewer.RefreshNewData(self)
             
     def RefreshViewOnNewData(self, *args, **kwargs):
         if self:
             self.RefreshNewData(*args, **kwargs)
+            self.TimerAccessLock.acquire()
             self.LastRefreshTimer = Timer(REFRESH_PERIOD, self.ShouldRefresh)
             self.LastRefreshTimer.start()
+            self.TimerAccessLock.release()
     
     def RefreshNewData(self, *args, **kwargs):
         self.Inhibit(False)