Browse Source

attempt to fix trac https://trac.osgeo.org/grass/ticket/483
(merge from relbr64, https://trac.osgeo.org/grass/changeset/38334)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38336 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 16 years ago
parent
commit
f087d747b6
1 changed files with 20 additions and 6 deletions
  1. 20 6
      gui/wxpython/gui_modules/mapdisp.py

+ 20 - 6
gui/wxpython/gui_modules/mapdisp.py

@@ -1362,7 +1362,7 @@ class MapFrame(wx.Frame):
                 vectstr += "%s," % name
 
         # use display region settings instead of computation region settings
-        tmpreg = os.getenv("GRASS_REGION")
+        self.tmpreg = os.getenv("GRASS_REGION")
         os.environ["GRASS_REGION"] = self.Map.SetRegion(windres=False)
         
         # build query commands for any selected rasters and vectors
@@ -1398,18 +1398,32 @@ class MapFrame(wx.Frame):
         if self._layerManager:
             if raststr:
                 self._layerManager.goutput.RunCmd(rcmd,
-                                                  compReg=False)
+                                                  compReg=False,
+                                                  onDone = self._QueryMapDone)
             if vectstr:
-                self._layerManager.goutput.RunCmd(vcmd)
+                self._layerManager.goutput.RunCmd(vcmd,
+                                                  onDone = self._QueryMapDone)
         else:
             if raststr:
                 gcmd.RunCommand(rcmd)
             if vectstr:
                 gcmd.RunCommand(vcmd)
+        
+    def _QueryMapDone(self, returncode):
+        """!Restore settings after querying (restore GRASS_REGION)
 
-        # restore GRASS_REGION
-        if tmpreg:
-            os.environ["GRASS_REGION"] = tmpreg
+        @param returncode command return code
+        """
+        if hasattr(self, "tmpreg"):
+            if self.tmpreg:
+                os.environ["GRASS_REGION"] = self.tmpreg
+            elif os.environ.has_key('GRASS_REGION'):
+                del os.environ["GRASS_REGION"]
+        elif os.environ.has_key('GRASS_REGION'):
+            del os.environ["GRASS_REGION"]
+        
+        if hasattr(self, "tmpreg"):
+            del self.tmpreg
         
     def QueryVector(self, x, y):
         """