Fix bug introduced when simplifying looping
Partially revert commit 7248f073f0
.
Deleting items during list iteration can lead to problems. In this
case an infinite loop was introduced in PR #975.
This commit is contained in:
parent
e390bb7c5b
commit
0ff0104a68
@ -275,9 +275,9 @@ class UIManager():
|
|||||||
parent = self.et_xml.find(".//*[@id='%s'].." % el_id)
|
parent = self.et_xml.find(".//*[@id='%s'].." % el_id)
|
||||||
if parent:
|
if parent:
|
||||||
# we found it, now delete original, inset updated
|
# we found it, now delete original, inset updated
|
||||||
for indx, p in enumerate(parent):
|
for indx in range(len(parent)):
|
||||||
if p.get('id') == el_id:
|
if parent[indx].get('id') == el_id:
|
||||||
del p
|
del parent[indx]
|
||||||
parent.insert(indx, update)
|
parent.insert(indx, update)
|
||||||
else:
|
else:
|
||||||
# updated item not present in original, just add it
|
# updated item not present in original, just add it
|
||||||
@ -314,7 +314,7 @@ class UIManager():
|
|||||||
# find parent of id'd element
|
# find parent of id'd element
|
||||||
element = self.et_xml.find(".//*[@id='%s']" % el_id)
|
element = self.et_xml.find(".//*[@id='%s']" % el_id)
|
||||||
if element: # element may have already been deleted
|
if element: # element may have already been deleted
|
||||||
for dummy in element:
|
for dummy in range(len(element)):
|
||||||
del element[0]
|
del element[0]
|
||||||
#results = ET.tostring(self.et_xml, encoding="unicode")
|
#results = ET.tostring(self.et_xml, encoding="unicode")
|
||||||
#LOG.info(results)
|
#LOG.info(results)
|
||||||
|
Loading…
Reference in New Issue
Block a user