Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
authorLaurent Bessard
Thu, 25 Apr 2013 15:30:50 +0200
changeset 1071 5e740fe71fbe
parent 1070 86ee833e33ef
child 1072 83b0815b8812
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
controls/LogViewer.py
--- a/controls/LogViewer.py	Thu Apr 25 17:04:41 2013 +0900
+++ b/controls/LogViewer.py	Thu Apr 25 15:30:50 2013 +0200
@@ -416,12 +416,15 @@
         new_messages.sort()
         if len(new_messages) > 0:
             self.HasNewData = True
-            old_length = len(self.LogMessages)
+            if self.CurrentMessage is not None:
+                current_is_last = self.GetNextMessage(self.CurrentMessage)[0] is None
+            else:
+                current_is_last = True
             for new_message in new_messages:
                 self.LogMessages.append(new_message)
                 self.LogMessagesTimestamp = numpy.append(self.LogMessagesTimestamp, [new_message.Timestamp])
-            if self.CurrentMessage is None or self.CurrentMessage == old_length - 1:
-                self.CurrentMessage = len(self.LogMessages) - 1
+            if current_is_last:
+                self.ScrollToLast(False)
                 self.ResetMessageToolTip()
                 self.MessageToolTipTimer.Stop()
                 self.ParentWindow.SelectTab(self)
@@ -757,13 +760,14 @@
             self.ScrollTimer.Start(int(period * 1000), True)
         self.ScrollSpeed = speed    
     
-    def ScrollToLast(self):
+    def ScrollToLast(self, refresh=True):
         if len(self.LogMessages) > 0:
             self.CurrentMessage = len(self.LogMessages) - 1
             message = self.LogMessages[self.CurrentMessage]
             if not self.FilterLogMessage(message):
                 message, self.CurrentMessage = self.GetPreviousMessage(self.CurrentMessage)
-            self.RefreshView()
+            if refresh:
+                self.RefreshView()
 
     def ScrollToFirst(self):
         if len(self.LogMessages) > 0: