From 95f77b1df197f996dd9be7f7f6dc8f8724f700fd Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 2 Oct 2016 13:46:29 +0200 Subject: [PATCH] quick frontend(contact_list): avoid crash when resource in cache has not priority --- frontends/src/quick_frontend/quick_contact_list.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index 3f0c980d..7c7e27cd 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -501,7 +501,9 @@ class ProfileContactList(object): resource_data[C.PRESENCE_STATUSES] = statuses if entity.bare not in self._specials: - priority_resource = max(resources_data, key=lambda res: resources_data[res][C.PRESENCE_PRIORITY]) + # we may have resources with no priority + # (when a cached value is added for a not connected resource) + priority_resource = max(resources_data, key=lambda res: resources_data[res].get(C.PRESENCE_PRIORITY, -2**32)) cache[C.CONTACT_MAIN_RESOURCE] = priority_resource self.update([entity], C.UPDATE_MODIFY, self.profile)