Philipp Hörist pushed to branch master at gajim / gajim

Commits:
850e2736 by Philipp Hörist at 2017-07-31T02:59:52+02:00
Correctly remove timeout source

Set source IDs to None after removing the source
except when shutting down, because the Control ist destroyed anyway

Only try to remove if we have a source ID

- - - - -


2 changed files:

- gajim/chat_control_base.py
- gajim/groupchat_control.py


Changes:

=====================================
gajim/chat_control_base.py
=====================================
--- a/gajim/chat_control_base.py
+++ b/gajim/chat_control_base.py
@@ -520,8 +520,10 @@ class ChatControlBase(MessageControl, 
ChatCommandProcessor, CommandTools):
     def shutdown(self):
         super(ChatControlBase, self).shutdown()
         # Disconnect timer callbacks
-        GLib.source_remove(self.possible_paused_timeout_id)
-        GLib.source_remove(self.possible_inactive_timeout_id)
+        if self.possible_paused_timeout_id:
+            GLib.source_remove(self.possible_paused_timeout_id)
+        if self.possible_inactive_timeout_id:
+            GLib.source_remove(self.possible_inactive_timeout_id)
         # PluginSystem: removing GUI extension points connected with 
ChatControlBase
         # instance object
         gajim.plugin_manager.remove_gui_extension_point('chat_control_base',
@@ -803,6 +805,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, 
CommandTools):
         jid = contact.jid
         current_state = contact.our_chatstate
         if current_state is False:  # jid doesn't support chatstates
+            self.possible_paused_timeout_id = None
             return False  # stop looping
 
         message_buffer = self.msg_textview.get_buffer()
@@ -832,6 +835,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, 
CommandTools):
 
         current_state = contact.our_chatstate
         if current_state is False: # jid doesn't support chatstates
+            self.possible_inactive_timeout_id = None
             return False # stop looping
 
         if self.mouse_over_in_last_5_secs or self.kbd_activity_in_last_5_secs:


=====================================
gajim/groupchat_control.py
=====================================
--- a/gajim/groupchat_control.py
+++ b/gajim/groupchat_control.py
@@ -2086,8 +2086,12 @@ class GroupchatControl(ChatControlBase):
         control = win.notebook.get_nth_page(ctrl_page)
 
         win.notebook.remove_page(ctrl_page)
-        GLib.source_remove(self.possible_paused_timeout_id)
-        GLib.source_remove(self.possible_inactive_timeout_id)
+        if self.possible_paused_timeout_id:
+            GLib.source_remove(self.possible_paused_timeout_id)
+            self.possible_paused_timeout_id = None
+        if self.possible_inactive_timeout_id:
+            GLib.source_remove(self.possible_inactive_timeout_id)
+            self.possible_inactive_timeout_id = None
         control.unparent()
         ctrl.parent_win = None
         self.send_chatstate('inactive', self.contact)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/850e273605d842f4681d75505d89a7cd9e0b286c
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to