Prechádzať zdrojové kódy

wxGUI: don't crash when history file is missing

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38103 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 rokov pred
rodič
commit
ed131c813c
1 zmenil súbory, kde vykonal 9 pridanie a 2 odobranie
  1. 9 2
      gui/wxpython/gui_modules/prompt.py

+ 9 - 2
gui/wxpython/gui_modules/prompt.py

@@ -386,8 +386,15 @@ class TextCtrlAutoComplete(wx.ComboBox, listmix.ColumnSorterMixin):
     def SetHistoryItems(self):
         """!Read history file and update combobox items"""
         env = grass.gisenv()
-        fileHistory = open(os.path.join(env['GISDBASE'], env['LOCATION_NAME'], env['MAPSET'],
-                                        '.bash_history'), 'r')
+        try:
+            fileHistory = open(os.path.join(env['GISDBASE'],
+                                            env['LOCATION_NAME'],
+                                            env['MAPSET'],
+                                            '.bash_history'), 'r')
+        except IOError:
+            self.SetItems([])
+            return
+        
         try:
             hist = []
             for line in fileHistory.readlines():