Explorar el Código

wxGUI: catch errors from the prompt
(merge https://trac.osgeo.org/grass/changeset/44589 from devbr6)


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

Martin Landa hace 14 años
padre
commit
5499764674

+ 6 - 1
gui/wxpython/gui_modules/goutput.py

@@ -735,7 +735,12 @@ class GMConsole(wx.SplitterWindow):
                             display.GetRender().GetListOfLayers(l_type = 'raster') +
                             display.GetRender().GetListOfLayers(l_type = 'vector'))
             
-            task = menuform.GUI().ParseCommand(event.cmd, show = None)
+            try:
+                task = menuform.GUI().ParseCommand(event.cmd, show = None)
+            except gcmd.GException:
+                task = None
+                return
+            
             for p in task.get_options()['params']:
                 if p.get('prompt', '') not in ('raster', 'vector'):
                     continue

+ 1 - 1
gui/wxpython/gui_modules/menuform.py

@@ -2247,7 +2247,7 @@ class GUI:
                             key = self.grass_task.firstParam
                             value = option
                         else:
-                            raise ValueError, _("Unable to parse command %s") % ' '.join(cmd)
+                            raise gcmd.GException, _("Unable to parse command %s") % ' '.join(cmd)
                     
                     element = self.grass_task.get_param(key, raiseError = False)
                     if not element:

+ 1 - 1
gui/wxpython/gui_modules/prompt.py

@@ -902,7 +902,7 @@ class GPromptSTC(GPrompt, wx.stc.StyledTextCtrl):
             self.InsertText(pos, '-')
             self.CharRight()
             self.toComplete = self.EntityToComplete()
-            if self.toComplete['entity'] == 'flags':
+            if self.toComplete['entity'] == 'flags' and self.cmdDesc:
                 if self.GetTextLeft()[-2:] == ' -': # complete e.g. --quite
                     for flag in self.cmdDesc.get_options()['flags']:
                         if len(flag['name']) == 1: