From 9ec0b88e0f0972071dee6fbc46b64d8d424f2b07 Mon Sep 17 00:00:00 2001
From: Dan Pascu <dan@ag-projects.com>
Date: Tue, 19 Oct 2010 10:59:12 +0000
Subject: [PATCH] Fixed exceptions when an account is removed while active

---
 blink/accounts.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/blink/accounts.py b/blink/accounts.py
index 63eaf51..e7ef5d4 100644
--- a/blink/accounts.py
+++ b/blink/accounts.py
@@ -119,22 +119,34 @@ class AccountModel(QAbstractListModel):
         self.endRemoveRows()
 
     def _NH_SIPAccountWillRegister(self, notification):
-        position = self.accounts.index(notification.sender)
+        try:
+            position = self.accounts.index(notification.sender)
+        except ValueError:
+            return
         self.accounts[position].registration_state = 'started'
         self.dataChanged.emit(self.index(position), self.index(position))
 
     def _NH_SIPAccountRegistrationDidSucceed(self, notification):
-        position = self.accounts.index(notification.sender)
+        try:
+            position = self.accounts.index(notification.sender)
+        except ValueError:
+            return
         self.accounts[position].registration_state = 'succeeded'
         self.dataChanged.emit(self.index(position), self.index(position))
 
     def _NH_SIPAccountRegistrationDidFail(self, notification):
-        position = self.accounts.index(notification.sender)
+        try:
+            position = self.accounts.index(notification.sender)
+        except ValueError:
+            return
         self.accounts[position].registration_state = 'failed'
         self.dataChanged.emit(self.index(position), self.index(position))
 
     def _NH_SIPAccountRegistrationDidEnd(self, notification):
-        position = self.accounts.index(notification.sender)
+        try:
+            position = self.accounts.index(notification.sender)
+        except ValueError:
+            return
         self.accounts[position].registration_state = 'ended'
         self.dataChanged.emit(self.index(position), self.index(position))
 
-- 
2.21.0