[GRASS-SVN] r66929 - grass/trunk/gui/wxpython/modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Nov 25 13:09:33 PST 2015
Author: martinl
Date: 2015-11-25 13:09:33 -0800 (Wed, 25 Nov 2015)
New Revision: 66929
Modified:
grass/trunk/gui/wxpython/modules/colorrules.py
Log:
wxGUI: fix colorrules preview including restoring original color table (no backport needed)
Modified: grass/trunk/gui/wxpython/modules/colorrules.py
===================================================================
--- grass/trunk/gui/wxpython/modules/colorrules.py 2015-11-25 20:32:40 UTC (rev 66928)
+++ grass/trunk/gui/wxpython/modules/colorrules.py 2015-11-25 21:09:33 UTC (rev 66929)
@@ -740,6 +740,7 @@
if self.mapType == 'vector' and self.properties['sourceColumn'] \
and self.properties['sourceColumn'] != 'cat':
cmd.append('column=%s' % self.properties['sourceColumn'])
+
cmd = cmdlist_to_tuple(cmd)
ret = RunCommand(cmd[0], **cmd[1])
if ret != 0:
@@ -799,7 +800,8 @@
title = _('Create new color table for raster map'), **kwargs)
self._initLayer()
-
+ self.Map.GetRenderMgr().renderDone.connect(self._restoreColorTable)
+
# self.SetMinSize(self.GetSize())
self.SetMinSize((650, 700))
@@ -906,29 +908,33 @@
mapset = grass.find_file(self.inmap, element = 'cell')['mapset']
if not mapset:
return
- old_colrtable = None
+ self._tmp = tmp
+ self._old_colrtable = None
if mapset == grass.gisenv()['MAPSET']:
- old_colrtable = grass.find_file(name = name, element = 'colr')['file']
+ self._old_colrtable = grass.find_file(name = name, element = 'colr')['file']
else:
- old_colrtable = grass.find_file(name = name, element = 'colr2/' + mapset)['file']
+ self._old_colrtable = grass.find_file(name = name, element = 'colr2/' + mapset)['file']
- if old_colrtable:
- colrtemp = utils.GetTempfile()
- shutil.copyfile(old_colrtable, colrtemp)
+ if self._old_colrtable:
+ self._colrtemp = utils.GetTempfile()
+ shutil.copyfile(self._old_colrtable, self._colrtemp)
- ColorTable.DoPreview(self, ltype, cmdlist)
-
+ ColorTable.DoPreview(self, ltype, cmdlist)
+
+ def _restoreColorTable(self):
# restore previous color table
- if tmp:
- if old_colrtable:
- shutil.copyfile(colrtemp, old_colrtable)
- os.remove(colrtemp)
+ if self._tmp:
+ if self._old_colrtable:
+ shutil.copyfile(self._colrtemp, self._old_colrtable)
+ os.remove(self._colrtemp)
+ del self._colrtemp, self._old_colrtable
else:
RunCommand('r.colors',
parent = self,
flags = 'r',
map = self.inmap)
-
+ del self._tmp
+
def OnHelp(self, event):
"""Show GRASS manual page"""
cmd = 'r.colors'
More information about the grass-commit
mailing list