[kupfer] plugin.pidgin: Don't add to update queue during teardown



commit 0e78587208443192ba18c58655ae9bf4fcb6dab7
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Fri Nov 6 21:15:52 2009 +0100

    plugin.pidgin: Don't add to update queue during teardown
    
    If events come in after we have started tearing down Kupfer, it might
    be we try to add to the buddy update queue, even though it is already
    set to None and deleted. Guard against this.

 kupfer/plugin/pidgin.py |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/plugin/pidgin.py b/kupfer/plugin/pidgin.py
index 0b074a1..cde9ebd 100644
--- a/kupfer/plugin/pidgin.py
+++ b/kupfer/plugin/pidgin.py
@@ -223,11 +223,16 @@ class ContactsSource(AppLeafContentMixin, Source, PicklingHelperMixin):
 		self._buddy_update_queue.clear()
 		self.mark_for_update()
 
-	def _buddy_signed_on(self, buddy):
-		if buddy not in self.all_buddies:
+	def _buddy_needs_update(self, buddy):
+		"""add @buddy to the update queue"""
+		if self._buddy_update_queue is not None:
 			self._buddy_update_queue.add(buddy)
 			self._buddy_update_timer.set(1, self._update_pending)
 
+	def _buddy_signed_on(self, buddy):
+		if buddy not in self.all_buddies:
+			self._buddy_needs_update(buddy)
+
 	def _buddy_signed_off(self, buddy):
 		if buddy in self.all_buddies:
 			del self.all_buddies[buddy]
@@ -236,8 +241,7 @@ class ContactsSource(AppLeafContentMixin, Source, PicklingHelperMixin):
 	def _buddy_status_changed(self, buddy, old, new):
 		'''Callback when status is changed reload the entry
 		which get the new status'''
-		self._buddy_update_queue.add(buddy)
-		self._buddy_update_timer.set(1, self._update_pending)
+		self._buddy_needs_update(buddy)
 
 	def _install_dbus_signal(self):
 		'''Add signals to pidgin when buddy goes offline or



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]