[GRASS-SVN] r68201 - grass/trunk/gui/wxpython/gmodeler
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 1 06:47:24 PDT 2016
Author: martinl
Date: 2016-04-01 06:47:24 -0700 (Fri, 01 Apr 2016)
New Revision: 68201
Modified:
grass/trunk/gui/wxpython/gmodeler/frame.py
grass/trunk/gui/wxpython/gmodeler/model.py
Log:
wxGUI/gmodeler: avoid recursive deletion when undefining module parameters
Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py 2016-04-01 12:39:45 UTC (rev 68200)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py 2016-04-01 13:47:24 UTC (rev 68201)
@@ -838,7 +838,7 @@
if not p.get('value', ''):
data = layer.FindData(p.get('name', ''))
if data:
- remList, upList = self.model.RemoveItem(data)
+ remList, upList = self.model.RemoveItem(data, layer)
for item in remList:
self.canvas.diagram.RemoveShape(item)
item.__del__()
Modified: grass/trunk/gui/wxpython/gmodeler/model.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/model.py 2016-04-01 12:39:45 UTC (rev 68200)
+++ grass/trunk/gui/wxpython/gmodeler/model.py 2016-04-01 13:47:24 UTC (rev 68201)
@@ -192,17 +192,18 @@
"""Reset model"""
self.items = list()
- def RemoveItem(self, item):
+ def RemoveItem(self, item, reference=None):
"""Remove item from model
+ :item: item to be removed
+ :reference: reference item valid for deletion
+
:return: list of related items to remove/update
"""
relList = list()
upList = list()
+ doRemove = True
- if item in self.items:
- self.items.remove(item)
-
if isinstance(item, ModelAction):
for rel in item.GetRelations():
relList.append(rel)
@@ -214,17 +215,24 @@
elif isinstance(item, ModelData):
for rel in item.GetRelations():
+ otherItem = rel.GetTo() if rel.GetFrom() == item else rel.GetFrom()
+ if reference and reference != otherItem:
+ doRemove = False
+ continue # avoid recursive deletion
relList.append(rel)
- if rel.GetFrom() == self:
- relList.append(rel.GetTo())
- else:
- relList.append(rel.GetFrom())
-
+ if reference and reference != otherItem:
+ relList.append(otherItem)
+ if not doRemove:
+ upList.append(item)
+
elif isinstance(item, ModelLoop):
for rel in item.GetRelations():
relList.append(rel)
for action in self.GetItems():
action.UnSetBlock(item)
+
+ if doRemove and item in self.items:
+ self.items.remove(item)
return relList, upList
More information about the grass-commit
mailing list