[GRASS-SVN] r38334 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 9 14:14:55 EDT 2009


Author: martinl
Date: 2009-07-09 14:14:54 -0400 (Thu, 09 Jul 2009)
New Revision: 38334

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
Log:
attempt to fix trac #483


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2009-07-09 14:12:27 UTC (rev 38333)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2009-07-09 18:14:54 UTC (rev 38334)
@@ -3530,7 +3530,7 @@
                 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
@@ -3567,19 +3567,33 @@
         # parse query command(s)
         if self.gismanager:
             if rcmd:
-                self.gismanager.goutput.RunCmd(rcmd, compReg=False)
+                self.gismanager.goutput.RunCmd(rcmd, compReg=False,
+                                               onDone = self._QueryMapDone)
             if vcmd:
-                self.gismanager.goutput.RunCmd(vcmd)
+                self.gismanager.goutput.RunCmd(vcmd,
+                                               onDone = self._QueryMapDone)
         else:
             if rcmd:
                 gcmd.Command(rcmd)
             if vcmd:
                 gcmd.Command(vcmd)
 
-        # restore GRASS_REGION
-        if tmpreg:
-            os.environ["GRASS_REGION"] = tmpreg
+    def _QueryMapDone(self, returncode):
+        """!Restore settings after querying (restore GRASS_REGION)
+
+        @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):
         """
         Query vector map layer features



More information about the grass-commit mailing list