From d040cc13fc70592531f3634b49158b9100c169fb Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Thu, 20 Apr 2006 16:57:43 +0000
Subject: [PATCH] be sure chat_control.contact is never None, even when server
 connection is brocken. Fixes #1878

---
 src/chat_control.py    | 8 +++++---
 src/common/contacts.py | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/chat_control.py b/src/chat_control.py
index 03b01244a2..ded91bd4b7 100644
--- a/src/chat_control.py
+++ b/src/chat_control.py
@@ -1618,8 +1618,10 @@ class ChatControl(ChatControlBase):
 	def got_connected(self):
 		ChatControlBase.got_connected(self)
 		# Refreshing contact
-		self.contact = gajim.contacts.get_contact_with_highest_priority(
+		contact = gajim.contacts.get_contact_with_highest_priority(
 			self.account, self.contact.jid)
-		if isinstance(self.contact, GC_Contact):
-			self.contact = gajim.contacts.contact_from_gc_contact(self.contact)
+		if isinstance(contact, GC_Contact):
+			contact = gajim.contacts.contact_from_gc_contact(contact)
+		if contact:
+			self.contact = contact
 		self.draw_banner()
diff --git a/src/common/contacts.py b/src/common/contacts.py
index 924f3df086..3826cec72f 100644
--- a/src/common/contacts.py
+++ b/src/common/contacts.py
@@ -212,7 +212,7 @@ class Contacts:
 			# jid may be a fake jid, try it
 			room, nick = jid.split('/')
 			contact = self.get_gc_contact(account, room, nick)
-			return contact or []
+			return contact
 		return self.get_highest_prio_contact_from_contacts(contacts)
 
 	def get_first_contact_from_jid(self, account, jid):
-- 
GitLab