Patch: set proper locks on tny_gtk_header_list_model_set_show_latest



	Hi,

	This patch adds proper locks on set_show_latest, to avoid problems of
concurrency if one thread is adding items to the model while another
thread changes the set_show_latest status.

	Changelog entry:
	* libtinymailui-gtk/tny-gtk-header-list-model.c: add proper
	locks on set_show_latest method to avoid concurrency problems.



-- 
José Dapena Paz <jdapena igalia com>
Igalia
diff --git a/ChangeLog b/ChangeLog
index 2b78740..55e3031 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-02-15  Jose Dapena Paz  <jdapena igalia com>
+
+	* libtinymailui-gtk/tny-gtk-header-list-model.c: add proper
+	locks on set_show_latest method to avoid concurrency problems.
+
 2010-02-10  Jose Dapena Paz  <jdapena igalia com>
 
 	* libtinymailui-gtk/tny-gtk-header-list-model.c:
diff --git a/libtinymailui-gtk/tny-gtk-header-list-model.c b/libtinymailui-gtk/tny-gtk-header-list-model.c
index 62f3ead..a2ca5c0 100644
--- a/libtinymailui-gtk/tny-gtk-header-list-model.c
+++ b/libtinymailui-gtk/tny-gtk-header-list-model.c
@@ -1478,6 +1478,9 @@ tny_gtk_header_list_model_set_show_latest (TnyGtkHeaderListModel *self, gint sho
 	TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self);
 	gint recover_latest = 0;
 
+	g_static_rec_mutex_lock (priv->iterator_lock);
+	g_static_rec_mutex_lock (priv->ra_lock);
+
 	if (priv->not_latest_items->len > 0 && show_latest_n == 0) {
 		/* recover all elements */
 		recover_latest = priv->not_latest_items->len;
@@ -1512,6 +1515,9 @@ tny_gtk_header_list_model_set_show_latest (TnyGtkHeaderListModel *self, gint sho
 
 	priv->show_latest = show_latest_n;
 
+	g_static_rec_mutex_unlock (priv->ra_lock);
+	g_static_rec_mutex_unlock (priv->iterator_lock);
+
 }
 
 gint 


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