[blam] Add locks



commit baab343dbf4f57e2ee269002a8c89f4cb8c2c839
Author: Carlos Martín Nieto <carlos cmartin tk>
Date:   Thu Mar 3 02:08:57 2011 +0100

    Add locks
    
    Signed-off-by: Carlos Martín Nieto <carlos cmartin tk>

 src/Channel.cs |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/Channel.cs b/src/Channel.cs
index 483ef55..af852a0 100644
--- a/src/Channel.cs
+++ b/src/Channel.cs
@@ -182,14 +182,16 @@ namespace Imendio.Blam {
 			bool updated = false;
             Item item;
 
-			foreach(string id in item_list){
-                item = store.Items[id] as Item;
-				if (item.Unread) {
-					item.SetUnread (false, false);
-					updated = true;
-                    EmitUpdated();
-				}
-			}
+            lock(obj){
+                foreach(string id in item_list){
+                    item = store.Items[id] as Item;
+                    if (item.Unread) {
+                        item.SetUnread (false, false);
+                        updated = true;
+                        EmitUpdated();
+                    }
+                }
+            }
 
 			return updated;
 		}
@@ -244,7 +246,9 @@ namespace Imendio.Blam {
         public void Add(Item item)
         {
             store.Add(item);
-            item_list.Add(item.Id);
+            lock(obj){
+                item_list.Add(item.Id);
+            }
             (store.Items[item.Id] as Item).Updated += ItemUpdated;
         }
 



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