[evolution-data-server/gnome-3-24] Bug 782096 - Folder unread count sometimes doesn't update properly
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-24] Bug 782096 - Folder unread count sometimes doesn't update properly
- Date: Mon, 22 May 2017 17:18:44 +0000 (UTC)
commit 8852b1320593456e2aa1118da33955ef2e6c03e6
Author: Milan Crha <mcrha redhat com>
Date: Mon May 22 19:16:41 2017 +0200
Bug 782096 - Folder unread count sometimes doesn't update properly
src/camel/camel-folder-summary.c | 13 ++++++++++++-
src/camel/camel-message-info.c | 15 ++++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/src/camel/camel-folder-summary.c b/src/camel/camel-folder-summary.c
index 5d76801..6094f42 100644
--- a/src/camel/camel-folder-summary.c
+++ b/src/camel/camel-folder-summary.c
@@ -145,6 +145,9 @@ enum {
G_DEFINE_TYPE (CamelFolderSummary, camel_folder_summary, G_TYPE_OBJECT)
+/* Private function */
+void _camel_message_info_unset_summary (CamelMessageInfo *mi);
+
static gboolean
remove_each_item (gpointer uid,
gpointer mi,
@@ -160,7 +163,7 @@ remove_each_item (gpointer uid,
static void
remove_all_loaded (CamelFolderSummary *summary)
{
- GSList *to_remove_infos = NULL;
+ GSList *to_remove_infos = NULL, *link;
g_return_if_fail (CAMEL_IS_FOLDER_SUMMARY (summary));
@@ -168,6 +171,14 @@ remove_all_loaded (CamelFolderSummary *summary)
g_hash_table_foreach_remove (summary->priv->loaded_infos, remove_each_item, &to_remove_infos);
+ for (link = to_remove_infos; link; link = g_slist_next (link)) {
+ CamelMessageInfo *mi = link->data;
+
+ /* Dirty hack, to have CamelWeakRefGroup properly cleared,
+ when the message info leaks due to ref/unref imbalance. */
+ _camel_message_info_unset_summary (mi);
+ }
+
g_slist_free_full (to_remove_infos, g_object_unref);
camel_folder_summary_unlock (summary);
diff --git a/src/camel/camel-message-info.c b/src/camel/camel-message-info.c
index d9fd7ea..35cd1ac 100644
--- a/src/camel/camel-message-info.c
+++ b/src/camel/camel-message-info.c
@@ -947,6 +947,17 @@ camel_message_info_init (CamelMessageInfo *mi)
g_rec_mutex_init (&mi->priv->property_lock);
}
+/* Private function */
+void _camel_message_info_unset_summary (CamelMessageInfo *mi);
+
+void
+_camel_message_info_unset_summary (CamelMessageInfo *mi)
+{
+ g_return_if_fail (CAMEL_IS_MESSAGE_INFO (mi));
+
+ camel_weak_ref_group_set (mi->priv->summary_wrg, NULL);
+}
+
/**
* camel_message_info_new:
* @summary: (nullable) (type CamelFolderSummary): parent #CamelFolderSummary object, or %NULL
@@ -1167,6 +1178,7 @@ camel_message_info_update_summary_and_folder (CamelMessageInfo *mi,
summary = camel_message_info_ref_summary (mi);
if (summary) {
CamelFolder *folder;
+ CamelMessageInfo *in_summary_mi = NULL;
const gchar *uid;
uid = camel_message_info_pooldup_uid (mi);
@@ -1174,7 +1186,7 @@ camel_message_info_update_summary_and_folder (CamelMessageInfo *mi,
/* This is for cases when a new message info had been created,
but not added into the summary yet. */
if (uid && camel_folder_summary_check_uid (summary, uid) &&
- camel_folder_summary_peek_loaded (summary, uid) == mi) {
+ (in_summary_mi = camel_folder_summary_peek_loaded (summary, uid)) == mi) {
if (update_counts) {
camel_folder_summary_lock (summary);
g_object_freeze_notify (G_OBJECT (summary));
@@ -1195,6 +1207,7 @@ camel_message_info_update_summary_and_folder (CamelMessageInfo *mi,
}
}
+ g_clear_object (&in_summary_mi);
g_clear_object (&summary);
camel_pstring_free (uid);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]