[GRASS-SVN] r43003 - grass/branches/develbranch_6/gui/wxpython
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 4 14:40:09 EDT 2010
Author: martinl
Date: 2010-08-04 18:40:09 +0000 (Wed, 04 Aug 2010)
New Revision: 43003
Modified:
grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: don't override workspace file when failed
(merge r43002 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py 2010-08-04 18:39:05 UTC (rev 43002)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py 2010-08-04 18:40:09 UTC (rev 43003)
@@ -26,6 +26,7 @@
import getopt
import platform
import signal
+import tempfile
### XML
try:
@@ -837,30 +838,30 @@
def SaveToWorkspaceFile(self, filename):
"""!Save layer tree layout to workspace file
-
+
Return True on success, False on error
"""
-
+ tmpfile = tempfile.TemporaryFile(mode='w+b')
try:
- file = open(filename, "w")
- except IOError:
- wx.MessageBox(parent=self,
- message=_("Unable to open workspace file <%s> for writing.") % filename,
- caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+ workspace.WriteWorkspaceFile(lmgr = self, file = tmpfile)
+ except StandardError, e:
+ gcmd.GError(parent = self,
+ message = _("Writing current settings to workspace file "
+ "failed."))
return False
-
+
try:
- workspace.WriteWorkspaceFile(lmgr=self, file=file)
- except StandardError, e:
- file.close()
- wx.MessageBox(parent=self,
- message=_("Writing current settings to workspace file failed (%s)." % e),
- caption=_("Error"),
- style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+ mfile = open(filename, "w")
+ tmpfile.seek(0)
+ for line in tmpfile.readlines():
+ mfile.write(line)
+ except IOError:
+ gcmd.GError(parent = self,
+ message = _("Unable to open file <%s> for writing.") % filename)
return False
-
- file.close()
+ mfile.close()
+
return True
def OnWorkspaceClose(self, event = None):
More information about the grass-commit
mailing list