Infinite recursion trying to check all elements of a TreeCtrl
- by mavnn
I have a TreeCtrl in which more than one Item can be assigned the same object as PyData. When the object is updated, I want to update all of the items in the tree which have that object as their PyData.
I thought the following code would solve the problem quite neatly, but for some reason the logical test (current != self.GetFirstVisibleItem()) always returns true leading to infinite recursion. Can anyone explain why?
def RefreshNodes(self, obj, current=None):
print "Entered refresh"
current = current or self.GetFirstVisibleItem()
if current.IsOk():
print self.GetPyData(current).name
if self.GetPyData(current) == obj:
self.RefreshNode(current)
current = self.GetNextVisible(current)
if current != self.GetFirstVisibleItem():
self.RefreshNodes(obj, current)
Edit: the above is obviously part of a class based on wx.TreeCtrl