[evolution-data-server] Bug #724729 - camel-folder.c:folder_changed() blocks the UI thread
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #724729 - camel-folder.c:folder_changed() blocks the UI thread
- Date: Thu, 20 Feb 2014 10:33:38 +0000 (UTC)
commit 4921a844a8946a0d0aacc0986d0ab9979de054b9
Author: Milan Crha <mcrha redhat com>
Date: Thu Feb 20 11:34:03 2014 +0100
Bug #724729 - camel-folder.c:folder_changed() blocks the UI thread
camel/camel-folder-summary.c | 36 ++++++++++++++++++++++++++++++++++++
camel/camel-folder-summary.h | 3 +++
camel/camel-folder.c | 31 ++++++++++++++++++++++++++-----
3 files changed, 65 insertions(+), 5 deletions(-)
---
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 7fc0899..3cf711a 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -1916,6 +1916,8 @@ message_info_from_uid (CamelFolderSummary *summary,
*
* Returns: the summary item, or %NULL if the uid @uid is not available
*
+ * See camel_folder_summary_get_info_flags().
+ *
* Since: 3.4
**/
CamelMessageInfo *
@@ -1933,6 +1935,40 @@ camel_folder_summary_get (CamelFolderSummary *summary,
return class->message_info_from_uid (summary, uid);
}
+/**
+ * camel_folder_summary_get_info_flags:
+ * @summary: a #CamelFolderSummary object
+ * @uid: a uid
+ *
+ * Retrieve CamelMessageInfo::flags for a message info with UID @uid.
+ * This is much quicker than camel_folder_summary_get(), because it
+ * doesn't require reading the message info from a disk.
+ *
+ * Returns: the flags currently stored for message info with UID @uid,
+ * or (~0) on error
+ *
+ * Since: 3.12
+ **/
+guint32
+camel_folder_summary_get_info_flags (CamelFolderSummary *summary,
+ const gchar *uid)
+{
+ gpointer ptr_uid = NULL, ptr_flags = NULL;
+
+ g_return_val_if_fail (CAMEL_IS_FOLDER_SUMMARY (summary), (~0));
+ g_return_val_if_fail (uid != NULL, (~0));
+
+ camel_folder_summary_lock (summary);
+ if (!g_hash_table_lookup_extended (summary->priv->uids, uid, &ptr_uid, &ptr_flags)) {
+ camel_folder_summary_unlock (summary);
+ return (~0);
+ }
+
+ camel_folder_summary_unlock (summary);
+
+ return GPOINTER_TO_UINT (ptr_flags);
+}
+
static CamelMessageContentInfo *
perform_content_info_load_from_db (CamelFolderSummary *summary,
CamelMIRecord *mir)
diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h
index bcd631c..ae8483a 100644
--- a/camel/camel-folder-summary.h
+++ b/camel/camel-folder-summary.h
@@ -468,6 +468,9 @@ gboolean camel_folder_summary_check_uid (CamelFolderSummary *summary,
CamelMessageInfo *
camel_folder_summary_get (CamelFolderSummary *summary,
const gchar *uid);
+guint32 camel_folder_summary_get_info_flags
+ (CamelFolderSummary *summary,
+ const gchar *uid);
GPtrArray * camel_folder_summary_get_array (CamelFolderSummary *summary);
void camel_folder_summary_free_array (GPtrArray *array);
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index fe84efd..a7a5bb4 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -290,6 +290,29 @@ folder_filter (CamelSession *session,
if (junk_filter != NULL)
g_object_ref (junk_filter);
+ /* Reset junk learn flag so that we don't process it again */
+ if (data->junk) {
+ for (i = 0; i < data->junk->len; i++) {
+ info = camel_folder_summary_get (data->folder->summary, data->junk->pdata[i]);
+ if (!info)
+ continue;
+
+ camel_message_info_set_flags (info, CAMEL_MESSAGE_JUNK_LEARN, 0);
+ camel_message_info_unref (info);
+ }
+ }
+
+ if (data->notjunk) {
+ for (i = 0; i < data->notjunk->len; i++) {
+ info = camel_folder_summary_get (data->folder->summary, data->notjunk->pdata[i]);
+ if (!info)
+ continue;
+
+ camel_message_info_set_flags (info, CAMEL_MESSAGE_JUNK_LEARN, 0);
+ camel_message_info_unref (info);
+ }
+ }
+
if (data->junk) {
gboolean success = TRUE;
@@ -1070,7 +1093,7 @@ folder_changed (CamelFolder *folder,
CamelMessageFlags flags;
for (i = 0; i < info->uid_changed->len; i++) {
- flags = camel_folder_get_message_flags (folder, info->uid_changed->pdata[i]);
+ flags = camel_folder_summary_get_info_flags (folder->summary,
info->uid_changed->pdata[i]);
if (flags & CAMEL_MESSAGE_JUNK_LEARN) {
if (flags & CAMEL_MESSAGE_JUNK) {
if (!junk)
@@ -1081,10 +1104,8 @@ folder_changed (CamelFolder *folder,
notjunk = g_ptr_array_new ();
g_ptr_array_add (notjunk, g_strdup (info->uid_changed->pdata[i]));
}
- /* reset junk learn flag so that we don't process it again*/
- camel_folder_set_message_flags (
- folder, info->uid_changed->pdata[i],
- CAMEL_MESSAGE_JUNK_LEARN, 0);
+
+ /* the flag will be unset in the thread, to not block the UI/main thread */
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]