Re: Patch: load summary on processing folder-tracking-changed



El vie, 24-07-2009 a las 15:49 +0200, Philip Van Hoof escribió:
> On Fri, 2009-07-24 at 15:38 +0200, José Dapena Paz wrote:
> > -       if (!g_static_rec_mutex_trylock (priv->folder_lock)) {
> > +       _tny_camel_folder_reason (priv);
> > +       if (!load_folder_no_lock (priv)) {
> >                 g_static_rec_mutex_unlock (priv->folder_lock);
> >                 return;
> >         }
> 
> 
> You are not taking the folder_reason in case load_folder_no_lock failed.

	I swear I didn't drunk on implementing the new patch.

	Hope this time it's ok.


-- 
José Dapena Paz <jdapena igalia com>
Igalia
diff --git a/ChangeLog b/ChangeLog
index f9bdf84..a3fc93c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,12 @@
 	coming from server, summary is corrupt. We were iterating wrongly to
 	remove the extra elements, and could cause a crash.
 
+	* libtinymail-camel/tny-camel-folder.c (folder_tracking_changed):
+	reimplemented to load the summary when we get a folder changed
+	event from camel, and use the standard folder_changed handler.
+	Avoids crashes if the camel folder is freed earlier than
+	folder changed handling finishes.
+
 2009-07-27  Lucas Maneos <tinymail subs maneos org>
 
 	* libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c:
diff --git a/libtinymail-camel/tny-camel-folder.c b/libtinymail-camel/tny-camel-folder.c
index 2fe9015..1e0e240 100644
--- a/libtinymail-camel/tny-camel-folder.c
+++ b/libtinymail-camel/tny-camel-folder.c
@@ -89,6 +89,8 @@ static GObjectClass *parent_class = NULL;
 
 
 static void tny_camel_folder_transfer_msgs_shared (TnyFolder *self, TnyList *headers, TnyFolder *folder_dst, gboolean delete_originals, TnyList *new_headers, GError **err);
+static gboolean load_folder_no_lock (TnyCamelFolderPriv *priv);
+static void folder_changed (CamelFolder *camel_folder, CamelFolderChangeInfo *info, gpointer user_data);
 
 
 
@@ -338,34 +340,23 @@ folder_tracking_changed (CamelFolder *camel_folder, CamelFolderChangeInfo *info,
 	   this notification will be received by folder_changed as
 	   well. Checks for folder_changed_id and loaded are harmless
 	   and unlikely needed */
-	if (priv->folder && priv->folder_changed_id && priv->loaded)
-		return;
-
-	if (!priv->handle_changes)
+	g_static_rec_mutex_lock (priv->folder_lock);
+	if (priv->folder && priv->folder_changed_id && priv->loaded) {
+		g_static_rec_mutex_unlock (priv->folder_lock);
 		return;
+	}
 
-	if (!g_static_rec_mutex_trylock (priv->folder_lock)) {
+	_tny_camel_folder_reason (priv);
+	if (!load_folder_no_lock (priv)) {
+		_tny_camel_folder_unreason (priv);
 		g_static_rec_mutex_unlock (priv->folder_lock);
 		return;
 	}
 
-	/* Update message counts */
-	priv->cached_length = (guint) camel_folder_get_message_count (camel_folder);
-	priv->unread_length = (guint) camel_folder_get_unread_message_count (camel_folder);
-	change = tny_folder_change_new (TNY_FOLDER (self));
-
-	/* Update iter */
-	update_iter_counts (priv);
+	folder_changed (camel_folder, info, priv);
+	_tny_camel_folder_unreason (priv);
 	g_static_rec_mutex_unlock (priv->folder_lock);
 
-	tny_folder_change_set_new_unread_count (change, priv->unread_length);
-	tny_folder_change_set_new_all_count (change, priv->cached_length);
-	priv->dont_fkill = TRUE;
-	notify_folder_observers_about_in_idle (TNY_FOLDER (self), change,
-					       TNY_FOLDER_PRIV_GET_SESSION (priv));
-	g_object_unref (change);
-	priv->dont_fkill = old;
-
 	return;
 }
 


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