[blam] Channel: NrOfUnreadItems: Check if item is null



commit fe2bb18db0851029cf68cf2878085c2e8ac52edf
Author: Carlos Martín Nieto <carlos cmartin tk>
Date:   Sun Oct 10 17:10:36 2010 +0100

    Channel: NrOfUnreadItems: Check if item is null

 src/Channel.cs |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/src/Channel.cs b/src/Channel.cs
index f20223d..b20d433 100644
--- a/src/Channel.cs
+++ b/src/Channel.cs
@@ -68,19 +68,21 @@ namespace Imendio.Blam {
 			}
 		}
 
-		public int NrOfUnreadItems {
-			get {
-				int unread = 0;
+        public int NrOfUnreadItems {
+            get {
+                int unread = 0;
 
-				foreach (string id in item_list) {
-					if ((store.Items[id] as Item).Unread == true) {
-						unread++;
-					}
-				}
+                Item item;
+                foreach (string id in item_list) {
+                    item = store.Items[id] as Item;
+                    if(item != null && item.Unread){
+                        ++unread;
+                    }
+                }
 
-				return unread;
-			}
-		}
+                return unread;
+            }
+        }
 
         public int NrOfNewItems {
             get {



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