diff options
Diffstat (limited to 'src/tabs/basetabs.py')
-rw-r--r-- | src/tabs/basetabs.py | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/src/tabs/basetabs.py b/src/tabs/basetabs.py index c2efc9bc..9212278d 100644 --- a/src/tabs/basetabs.py +++ b/src/tabs/basetabs.py @@ -35,7 +35,6 @@ from decorators import refresh_wrapper from logger import logger from text_buffer import TextBuffer from theming import get_theme, dump_tuple -from windows import g_lock # getters for tab colors (lambdas, so that they are dynamic) @@ -187,9 +186,8 @@ class Tab(object): @staticmethod def resize(scr): - with g_lock: - Tab.height, Tab.width = scr.getmaxyx() - windows.Win._tab_win = scr + Tab.height, Tab.width = scr.getmaxyx() + windows.Win._tab_win = scr def missing_command_callback(self, command_name): """ @@ -447,12 +445,9 @@ class ChatTab(Tab): self.text_win = None self._text_buffer = TextBuffer() self.chatstate = None # can be "active", "composing", "paused", "gone", "inactive" - # We keep a weakref of the event that will set our chatstate to "paused", so that + # We keep a reference of the event that will set our chatstate to "paused", so that # we can delete it or change it if we need to self.timed_event_paused = None - # if that’s None, then no paused chatstate was sent recently - # if that’s a weakref returning None, then a paused chatstate was sent - # since the last input # Keeps the last sent message to complete it easily in completion_correct, and to replace it. self.last_sent_message = None self.key_func['M-v'] = self.move_separator @@ -624,17 +619,12 @@ class ChatTab(Tab): """ if not config.get_by_tabname('send_chat_states', True, self.general_jid, True): return - if self.timed_event_paused: - # check the weakref - event = self.timed_event_paused() - if event: - # the event already exists: we just update - # its date - event.change_date(datetime.now() + timedelta(seconds=4)) - return + # First, cancel the delay if it already exists, before rescheduling + # it at a new date + self.cancel_paused_delay() new_event = timed_events.DelayedEvent(4, self.send_chat_state, 'paused') self.core.add_timed_event(new_event) - self.timed_event_paused = weakref.ref(new_event) + self.timed_event_paused = new_event def cancel_paused_delay(self): """ @@ -642,12 +632,9 @@ class ChatTab(Tab): Called for example when the input is emptied, or when the message is sent """ - if self.timed_event_paused: - event = self.timed_event_paused() - if event: - self.core.remove_timed_event(event) - del event - self.timed_event_paused = None + if self.timed_event_paused is not None: + self.core.remove_timed_event(self.timed_event_paused) + self.timed_event_paused = None def command_correct(self, line): """ @@ -737,7 +724,7 @@ class OneToOneTab(ChatTab): "check the features supported by the other party" if safeJID(self.get_dest_jid()).resource: self.core.xmpp.plugin['xep_0030'].get_info( - jid=self.get_dest_jid(), block=False, timeout=5, + jid=self.get_dest_jid(), timeout=5, callback=self.features_checked) def command_attention(self, message=''): |