dabo Commit
Revision 4488
Date: 2008-08-29 11:32:14 -0700 (Fri, 29 Aug 2008)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabo/changeset/4488

Changed:
U   trunk/dabo/ui/uiwx/dGrid.py

Log:
Worked around a substantial source of the flickering of dGrid on Windows, by 
caching the cell values for 10 seconds to avoid unneccesary calls to 
biz.getFieldVal(). This will probably improve performance on Mac and Lin as 
well, even though those platforms didn't exhibit the flickering. Now, the 
windows grid will flicker at most once every 10 seconds. Call grid.update() or 
grid.refresh() will clear all cached values immediately.

Diff:
Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2008-08-28 22:21:01 UTC (rev 4487)
+++ trunk/dabo/ui/uiwx/dGrid.py 2008-08-29 18:32:14 UTC (rev 4488)
@@ -30,9 +30,12 @@
 class dGridDataTable(wx.grid.PyGridTableBase):
        def __init__(self, parent):
                super(dGridDataTable, self).__init__()
+               self._clearCache()
                self.grid = parent
                self._initTable()
 
+       def _clearCache(self):
+               self.__cachedVals = {}
 
        def _initTable(self):
                self.colDefs = []
@@ -321,6 +324,16 @@
 
 
        def GetValue(self, row, col):
+               try:
+                       cv = self.__cachedVals.get((row, col))
+               except KeyError:
+                       cv = None
+
+               if cv:
+                       diff = time.time() - cv[1]
+                       if diff < 10:  ## if it's been less than this # of 
seconds.
+                               return cv[0]
+
                bizobj = self.grid.getBizobj()
                col_obj = self.grid.Columns[col]
                field = col_obj.DataField
@@ -338,6 +351,7 @@
                                ret = ""
                if ret is None:
                        ret = self.grid.NoneDisplay
+               self.__cachedVals[(row, col)] = (ret, time.time()) 
                return ret
 
        def getStringValue(self, val):
@@ -1866,6 +1880,7 @@
 
        def update(self):
                self.super()
+               self._Table._clearCache()
                self._syncRowCount()
                self._syncColumnCount()
                self._syncCurrentRow()
@@ -3008,6 +3023,7 @@
                        self._refreshAfterSort = False
                        self._restoreSort()
                        self._refreshAfterSort = ref
+               self._Table._clearCache()
                self._syncColumnCount()
                self._syncRowCount()
                self._syncCurrentRow()




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to