blam r647 - trunk/src



Author: cmartin
Date: Tue Sep 16 20:55:57 2008
New Revision: 647
URL: http://svn.gnome.org/viewvc/blam?rev=647&view=rev

Log:
Make sure it's safe to access ChannelGroup.Channels.

Modified:
   trunk/src/ChannelCollection.cs
   trunk/src/ChannelGroup.cs

Modified: trunk/src/ChannelCollection.cs
==============================================================================
--- trunk/src/ChannelCollection.cs	(original)
+++ trunk/src/ChannelCollection.cs	Tue Sep 16 20:55:57 2008
@@ -256,6 +256,8 @@
 	    }
 
         foreach(ChannelGroup group in Groups){
+            if(group.Channels.Count == 0)
+                    continue;
             foreach(Channel channel in group.Channels){
                 TimeSpan span = DateTime.Now.Subtract(channel.LastRefreshed);
                 if(span.TotalSeconds >= refreshRate * 60){

Modified: trunk/src/ChannelGroup.cs
==============================================================================
--- trunk/src/ChannelGroup.cs	(original)
+++ trunk/src/ChannelGroup.cs	Tue Sep 16 20:55:57 2008
@@ -34,6 +34,10 @@
         public int NrOfUnreadItems {
             get {
                 int nr = 0;
+
+                if(Channels.Count == 0)
+                    return nr;
+
                 foreach(Channel channel in Channels){
                     nr += channel.NrOfUnreadItems;
                 }
@@ -45,6 +49,10 @@
         public int NrOfItems {
             get {
                 int n = 0;
+
+                if(Channels.Count == 0)
+                    return n;
+
                 foreach(Channel channel in Channels){
                     n += channel.NrOfItems;
                 }
@@ -70,6 +78,12 @@
             }
         }
 
+        public ChannelGroup() : base()
+        {
+            if(Channels == null)
+                Channels = new ArrayList();
+        }
+
         public bool MarkAsRead()
         {
             bool ret = false;



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