[GRASS-SVN] r60492 - grass/branches/releasebranch_7_0/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 26 07:25:03 PDT 2014


Author: annakrat
Date: 2014-05-26 07:25:03 -0700 (Mon, 26 May 2014)
New Revision: 60492

Modified:
   grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py
Log:
wxGUI/import dlg: fix closing dialog, #2243 (merged from trunk, r59571)

Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py	2014-05-26 13:49:09 UTC (rev 60491)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py	2014-05-26 14:25:03 UTC (rev 60492)
@@ -1794,6 +1794,11 @@
         """
         pass
 
+    def OnCmdDone(self, cmd, returncode):
+        """!Do what has to be done after importing"""
+        pass
+
+
 class GdalImportDialog(ImportDialog):
     def __init__(self, parent, giface, ogr = False, link = False):
         """!Dialog for bulk import of various raster/vector data
@@ -1857,12 +1862,12 @@
         ext  = self.dsnInput.GetFormatExt()
         
         # determine data driver for PostGIS links
-        popOGR = False
+        self.popOGR = False
         if self.importType == 'ogr' and \
                 self.dsnInput.GetType() == 'db' and \
                 self.dsnInput.GetFormat() == 'PostgreSQL' and \
                 'GRASS_VECTOR_OGR' not in os.environ:
-            popOGR = True
+            self.popOGR = True
             os.environ['GRASS_VECTOR_OGR'] = '1'
         
         for layer, output in data:
@@ -1906,14 +1911,21 @@
                 cmd.append('--overwrite')
             
             # run in Layer Manager
-            self._giface.RunCmd(cmd, onDone=self.AddLayers)
-        
-        if popOGR:
+            self._giface.RunCmd(cmd, onDone=self.OnCmdDone)
+
+    def OnCmdDone(self, cmd, returncode):
+        """!Load layers and close if required"""
+        if not hasattr(self, 'AddLayers'):
+            return
+
+        self.AddLayers(cmd, returncode)
+
+        if self.popOGR:
             os.environ.pop('GRASS_VECTOR_OGR')
 
-        if self.closeOnFinish.IsChecked():
+        if returncode == 0 and self.closeOnFinish.IsChecked():
             self.Close()
-        
+
     def _getCommand(self):
         """!Get command"""
         if self.link:
@@ -2068,10 +2080,18 @@
                 cmd.append('--overwrite')
             
             # run in Layer Manager
-            self._giface.RunCmd(cmd, onDone=self.AddLayers)
-        
-        self.Close()
+            self._giface.RunCmd(cmd, onDone=self.OnCmdDone)
 
+    def OnCmdDone(self, cmd, returncode):
+        """!Load layers and close if required"""
+        if not hasattr(self, 'AddLayers'):
+            return
+
+        self.AddLayers(cmd, returncode)
+
+        if self.closeOnFinish.IsChecked():
+            self.Close()
+
     def OnSetDsn(self, event):
         """!Input DXF file defined, update list of layer widget"""
         path = event.GetString()



More information about the grass-commit mailing list