From 0ff0104a68d83a4c5005376e6d10fd9af2b529ef Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Mon, 14 Feb 2022 19:33:23 +0000 Subject: [PATCH] Fix bug introduced when simplifying looping Partially revert commit 7248f073f06f6a44ab48088679b45f3242436e28. Deleting items during list iteration can lead to problems. In this case an infinite loop was introduced in PR #975. --- gramps/gui/uimanager.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gramps/gui/uimanager.py b/gramps/gui/uimanager.py index aa4d90a92..fc5c46128 100644 --- a/gramps/gui/uimanager.py +++ b/gramps/gui/uimanager.py @@ -275,9 +275,9 @@ class UIManager(): parent = self.et_xml.find(".//*[@id='%s'].." % el_id) if parent: # we found it, now delete original, inset updated - for indx, p in enumerate(parent): - if p.get('id') == el_id: - del p + for indx in range(len(parent)): + if parent[indx].get('id') == el_id: + del parent[indx] parent.insert(indx, update) else: # updated item not present in original, just add it @@ -314,7 +314,7 @@ class UIManager(): # find parent of id'd element element = self.et_xml.find(".//*[@id='%s']" % el_id) if element: # element may have already been deleted - for dummy in element: + for dummy in range(len(element)): del element[0] #results = ET.tostring(self.et_xml, encoding="unicode") #LOG.info(results)