changeset 283:11cf3a259eaa

Iterate over copies, to avoid some issues with children changing in the loop
author Neil Muller <drnlmuller@gmail.com>
date Thu, 15 Sep 2011 21:44:26 +0200
parents 56cd71696dff
children 96b4ad9b4d30
files mamba/widgets/base.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mamba/widgets/base.py	Thu Sep 15 19:59:03 2011 +0200
+++ b/mamba/widgets/base.py	Thu Sep 15 21:44:26 2011 +0200
@@ -108,7 +108,7 @@
         last resort
         """
         if ev.type in (MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN):
-            for child in self.children:
+            for child in self.children[:]:
                 if child.rect.collidepoint(ev.pos):
                     if ev.type == MOUSEBUTTONDOWN and child.focussable:
                         child.grab_focus()
@@ -122,7 +122,7 @@
                         return True
         else:
             # Other events go to all children first
-            for child in self.children:
+            for child in self.children[:]:
                 if child.event(ev):
                     return True
         if super(Container, self).event(ev):