mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 03:50:06 +01:00
Fix DeleteChildren in HyperTreeList
The TreeListItem.DeleteChildren() method iterates over the list of a parent item's children (self._children) and calls tree.Delete(child) on each one (hypertreelist.py line 1365): for child in list(self._children): child.DeleteChildren(tree) if tree: tree.Delete(child) The TreeListMainWindow.Delete(item) method however removes the child from its parent's list directly (hypertreelist.py line 2546): parent = item.GetParent() if parent: parent.GetChildren().remove(item) # remove by value This ends up modifying the list as we are iterating over it. The end result is that every other child and its children do not get cleaned up properly before being deleted. The biggest issue being that any windows belonging to the children won't be destroyed, and instead orphaned in the control.
This commit is contained in:
@@ -1361,8 +1361,8 @@ class TreeListItem(GenericTreeItem):
|
||||
|
||||
:param `tree`: the main :class:`TreeListMainWindow` instance.
|
||||
"""
|
||||
|
||||
for child in self._children:
|
||||
# Iterate over copy of self._children as tree.Delete() will modify it.
|
||||
for child in list(self._children):
|
||||
child.DeleteChildren(tree)
|
||||
if tree:
|
||||
tree.Delete(child)
|
||||
|
||||
Reference in New Issue
Block a user