浏览代码

wxGUI/d.vect: avoid repetitive running of the same commands

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@42392 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 15 年之前
父节点
当前提交
4bdc3d9bf4
共有 2 个文件被更改,包括 15 次插入4 次删除
  1. 3 2
      gui/wxpython/gui_modules/gselect.py
  2. 12 2
      gui/wxpython/gui_modules/menuform.py

+ 3 - 2
gui/wxpython/gui_modules/gselect.py

@@ -693,7 +693,7 @@ class ColumnSelect(wx.ComboBox):
         if vector:
             self.InsertColumns(vector, layer)
                 
-    def InsertColumns(self, vector, layer, excludeKey = False, type = None):
+    def InsertColumns(self, vector, layer, excludeKey = False, type = None, dbInfo = None):
         """!Insert columns for a vector attribute table into the columns combobox
 
         @param vector vector name
@@ -701,7 +701,8 @@ class ColumnSelect(wx.ComboBox):
         @param excludeKey exclude key column from the list?
         @param type only columns of given type (given as list)
         """
-        dbInfo = VectorDBInfo(vector)
+        if not dbInfo:
+            dbInfo = VectorDBInfo(vector)
         
         try:
             table = dbInfo.GetTable(int(layer))

+ 12 - 2
gui/wxpython/gui_modules/menuform.py

@@ -206,6 +206,11 @@ class UpdateThread(Thread):
             map = pMap.get('value', '')
         else:
             map = None
+
+        # avoid running db.describe several times
+        cparams = dict()
+        cparams[map] = { 'dbInfo' : None,
+                         'layers' : None, }
         
         # update reference widgets
         for uid in p['wxId-bind']:
@@ -261,7 +266,9 @@ class UpdateThread(Thread):
                         table = pTable.get('value', '')
                 
             if name == 'LayerSelect':
-                self.data[win.InsertLayers] = { 'vector' : map }
+                if not cparams[map]['layers']:
+                    win.InsertLayers(vector = map)
+                    cparams[map]['layers'] = win.GetItems()
             
             elif name == 'LayerNameSelect':
                 # determine format
@@ -284,7 +291,10 @@ class UpdateThread(Thread):
                 
             elif name == 'ColumnSelect':
                 if map:
-                    self.data[win.InsertColumns] = { 'vector' : map, 'layer' : layer }
+                    if not cparams[map]['dbInfo']:
+                        cparams[map]['dbInfo'] = gselect.VectorDBInfo(map)
+                    self.data[win.InsertColumns] = { 'vector' : map, 'layer' : layer,
+                                                     'dbInfo' : cparams[map]['dbInfo'] }
                 else: # table
                     if driver and db:
                         self.data[win.InsertTableColumns] = { 'table' : pTable.get('value'),