From 9939aa4a0ee8d79c23688a70c91633eae9fda7c3 Mon Sep 17 00:00:00 2001 From: gimick Date: Sat, 17 Jul 2010 18:19:16 +0100 Subject: [PATCH] Log viewer - fixes for column sorting --- pyfpdb/GuiLogView.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pyfpdb/GuiLogView.py b/pyfpdb/GuiLogView.py index 127dc669..bb7992b4 100755 --- a/pyfpdb/GuiLogView.py +++ b/pyfpdb/GuiLogView.py @@ -24,6 +24,8 @@ import gtk import gobject import pango +import os +import traceback import logging # logging has been set up in fpdb.py or HUD_main.py, use their settings: log = logging.getLogger("logview") @@ -135,7 +137,7 @@ class GuiLogView: def loadLog(self): self.liststore.clear() - self.listcols = [] +# self.listcols = [] blanking listcols causes sortcols() to fail with index out of range # guesstimate number of lines in file if os.path.exists(self.logfile): @@ -155,6 +157,15 @@ class GuiLogView: # 2009-12-02 15:23:21,716 - config DEBUG config logger initialised l = l + 1 if l > startline: + # NOTE selecting a sort column and then switching to a log file + # with several thousand rows will send cpu 100% for a prolonged period. + # reason is that the append() method seems to sort every record as it goes, rather than + # pulling in the whole file and sorting at the end. + # one fix is to check if a column sort has been selected, reset to date/time asc + # append all the rows and then reselect the required sort order. + # Note: there is no easy method available to revert the list to an "unsorted" state. + # always defaulting to date/time asc doesn't work, because some rows do not have date/time info + # and would end up sorted out of context. if len(line) > 49 and line[23:26] == ' - ' and line[34:39] == ' ': iter = self.liststore.append( (line[0:23], line[26:32], line[39:46], line[48:].strip(), True) ) else: