summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-04-08 16:11:23 +0100
committerMaxime “pep” Buquet <pep@bouah.net>2019-04-08 16:11:23 +0100
commitdb2a22d09911d3af15f47ef4b2f045a793a15982 (patch)
treeed183f3280d558159927337c49b82c0360899caf
parent8d53ff71d1abc7170365d90117436c508cb60b29 (diff)
downloadpoezio-db2a22d09911d3af15f47ef4b2f045a793a15982.tar.gz
poezio-db2a22d09911d3af15f47ef4b2f045a793a15982.tar.bz2
poezio-db2a22d09911d3af15f47ef4b2f045a793a15982.tar.xz
poezio-db2a22d09911d3af15f47ef4b2f045a793a15982.zip
ChatTab: Oops. prevent recursion when using setters
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/tabs/basetabs.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index 3bf3dd29..a1c3f8d4 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -464,6 +464,8 @@ class ChatTab(Tab):
def __init__(self, core, jid: Union[JID, str]):
Tab.__init__(self, core)
+ self._jid = None
+ self._name = ''
self.name = jid
self.text_win = None
self.directed_presence = None
@@ -511,39 +513,39 @@ class ChatTab(Tab):
@property
def name(self) -> str:
- if self.jid is not None:
- return self.jid.full
- return self.name
+ if self._jid is not None:
+ return self._jid.full
+ return self._name
@name.setter
def name(self, value: Union[JID, str]) -> None:
if isinstance(value, JID):
- self.jid = value
+ self._jid = value
elif isinstance(value, str):
try:
value = JID(value)
if value.domain:
- self.jid = value
- self.name = value.full
+ self._jid = value
+ self._name = value.full
except InvalidJID:
- self.name = value
+ self._name = value
else:
raise TypeError("Name must be of type JID or str.")
@property
def jid(self) -> Optional[JID]:
- return self.jid
+ return self._jid
@jid.setter
def jid(self, value: Optional[JID]) -> None:
if value is None:
- self.jid = None
+ self._jid = None
return None
if not isinstance(value, JID):
raise TypeError("Jid must be of type Optional[JID].")
if not value.domain:
raise ValueError("Jid must contain at least a domain.")
- self.jid = value
+ self._jid = value
@property
def general_jid(self) -> JID: