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
This commit is contained in:
Philipp Hörist 2017-07-31 02:25:08 +02:00
parent 81566df8a1
commit 850e273605
2 changed files with 12 additions and 4 deletions

View File

@ -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:

View File

@ -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)