Browse Source

wxGUI: don't crash when unable to read settings file

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32335 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 17 years ago
parent
commit
807cde0343
1 changed files with 7 additions and 1 deletions
  1. 7 1
      gui/wxpython/gui_modules/preferences.py

+ 7 - 1
gui/wxpython/gui_modules/preferences.py

@@ -523,6 +523,7 @@ class Settings:
 
         try:
             file = open(filename, "r")
+            line = ''
             for line in file.readlines():
                 line = line.rstrip('%s' % os.linesep)
                 group, key = line.split(self.sep)[0:2]
@@ -541,9 +542,14 @@ class Settings:
                     value = self.__parseValue(value, read=True)
                     self.Append(settings, group, key, subkey, value)
                     idx += 2
-        finally:
+        except ValueError, e:
+            print >> sys.stderr, _("Error: Reading settings from file <%s> failed.\n"
+                                   "       Details: %s\n"
+                                   "       Line: '%s'") % (filename, e, line)
             file.close()
 
+        file.close()
+
     def SaveToFile(self, settings=None):
         """Save settings to the file"""
         if settings is None: