Browse Source

wxGUI/import dlg: fix closing dialog, https://trac.osgeo.org/grass/ticket/2243 (merged from trunk, https://trac.osgeo.org/grass/changeset/59571)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@60492 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 11 years ago
parent
commit
d44f4a3b78
1 changed files with 30 additions and 10 deletions
  1. 30 10
      gui/wxpython/gui_core/dialogs.py

+ 30 - 10
gui/wxpython/gui_core/dialogs.py

@@ -1794,6 +1794,11 @@ class ImportDialog(wx.Dialog):
         """
         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 @@ class GdalImportDialog(ImportDialog):
         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 @@ class GdalImportDialog(ImportDialog):
                 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,9 +2080,17 @@ class DxfImportDialog(ImportDialog):
                 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"""