Browse Source

Added some error traps for KeyErrors when unloading or loading maps in wxnviz

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@47991 15284696-431f-4ddb-bdfa-cd5b030d7da7
Michael Barton 13 years ago
parent
commit
84ebd4745e
1 changed files with 13 additions and 3 deletions
  1. 13 3
      gui/wxpython/gui_modules/nviz_mapdisp.py

+ 13 - 3
gui/wxpython/gui_modules/nviz_mapdisp.py

@@ -1215,7 +1215,10 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
             errorMsg = _("Unable to unload 3d raster map")
             errorMsg = _("Unable to unload 3d raster map")
             successMsg = _("3d raster map")
             successMsg = _("3d raster map")
         
         
-        id = data[nvizType]['object']['id']
+        if 'object' not in data[nvizType]:
+            return
+        else:
+            id = data[nvizType]['object']['id']
         
         
         if unloadFn(id) ==  0:
         if unloadFn(id) ==  0:
             self.log.WriteError("%s <%s>" % (errorMsg, layer.name))
             self.log.WriteError("%s <%s>" % (errorMsg, layer.name))
@@ -1323,7 +1326,7 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
         for vecType in vecTypes:
         for vecType in vecTypes:
             if 'object' not in data[vecType]:
             if 'object' not in data[vecType]:
                 continue
                 continue
-            
+
             id = data[vecType]['object']['id']
             id = data[vecType]['object']['id']
             
             
             if vecType ==  'lines':
             if vecType ==  'lines':
@@ -1339,7 +1342,7 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
             
             
             data[vecType].pop('object')
             data[vecType].pop('object')
             
             
-        if remove:
+        if remove and item in self.layers:
             self.layers.remove(item)
             self.layers.remove(item)
         
         
     def OnZoomToMap(self, event):
     def OnZoomToMap(self, event):
@@ -1775,6 +1778,13 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
             
             
             data = self.tree.GetPyData(item)[0]['nviz']
             data = self.tree.GetPyData(item)[0]['nviz']
             
             
+            for datatype in ['surface', 'volume']:
+                if 'object' not in data[datatype]:
+                    return -1
+            for datatype in ['points', 'lines']:
+                if 'object' not in data['vector'][datatype]:
+                    return -1
+            
             if type ==  'raster':
             if type ==  'raster':
                 return data['surface']['object']['id']
                 return data['surface']['object']['id']
             elif type ==  'vector':
             elif type ==  'vector':