Prevent some iteration problems

This commit is contained in:
mathieui 2012-04-27 23:42:22 +02:00
parent de63a1affd
commit 24341c8429
2 changed files with 4 additions and 4 deletions

View file

@ -242,7 +242,7 @@ class RosterGroup(object):
return 5
return PRESENCE_PRIORITY[show]
contact_list = self.contacts if not contact_filter\
else (contact for contact in self.contacts if contact_filter[0](contact, contact_filter[1]))
else [contact for contact in self.contacts.copy() if contact_filter[0](contact, contact_filter[1])]
return sorted(contact_list, key=compare_contact, reverse=True)
def toggle_folded(self):
@ -250,7 +250,7 @@ class RosterGroup(object):
def get_nb_connected_contacts(self):
l = 0
for contact in self.contacts:
for contact in self.contacts.copy():
if contact.resources:
l += 1
return l

View file

@ -1543,7 +1543,7 @@ class RosterWin(Win):
self.draw_roster_information(roster)
y = 1
show_offline = config.get('roster_show_offline', 'false') == 'true'
for group in roster.get_groups():
for group in roster.get_groups()[:]:
contacts_filtered = group.get_contacts(roster.contact_filter)
if (not show_offline and group.get_nb_connected_contacts() == 0) or not contacts_filtered:
continue # Ignore empty groups
@ -1555,7 +1555,7 @@ class RosterWin(Win):
y += 1
if group.folded:
continue
for contact in group.get_contacts(roster.contact_filter):
for contact in group.get_contacts(roster.contact_filter)[:]:
if not show_offline and len(contact) == 0:
continue
if y-1 == self.pos: