[evolution-ews] Bug 735799 - Workaround crash for messages with no item ID



commit b37c4dc23b4e3721db3238bdfdcde402a81fbd27
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 1 15:53:20 2014 +0200

    Bug 735799 - Workaround crash for messages with no item ID
    
    It can have a side effect of a missing message in the list, where
    the only chance to get it back will be with a removal of
    ~/.cache/evolution/mail/<ews-account-uid>/folders.db file.

 src/camel/camel-ews-folder.c |   21 ++++++++++++++++++++-
 src/camel/camel-ews-utils.c  |   20 ++++++++++++++++----
 2 files changed, 36 insertions(+), 5 deletions(-)
---
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index 493664c..f02a3ba 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -1422,9 +1422,20 @@ sync_updated_items (CamelEwsFolder *ews_folder,
 
        for (l = updated_items; l != NULL; l = g_slist_next (l)) {
                EEwsItem *item = (EEwsItem *) l->data;
-               const EwsId *id = e_ews_item_get_id (item);
+               const EwsId *id;
                CamelMessageInfo *mi;
 
+               if (!item)
+                       continue;
+
+               id = e_ews_item_get_id (item);
+               if (!id) {
+                       g_warning ("%s: Missing ItemId for item type %d (subject:%s)", G_STRFUNC, 
e_ews_item_get_item_type (item),
+                               e_ews_item_get_subject (item) ? e_ews_item_get_subject (item) : "???");
+                       g_object_unref (item);
+                       continue;
+               }
+
                /* Compare the item_type from summary as the updated items seems to
                 * arrive as generic types while its not the case */
                mi = camel_folder_summary_get (folder->summary, id->id);
@@ -1533,6 +1544,14 @@ sync_created_items (CamelEwsFolder *ews_folder,
 
                id = e_ews_item_get_id (item);
                item_type = e_ews_item_get_item_type (item);
+
+               if (!id) {
+                       g_warning ("%s: Missing ItemId for item type %d (subject:%s)", G_STRFUNC, item_type,
+                               e_ews_item_get_subject (item) ? e_ews_item_get_subject (item) : "???");
+                       g_object_unref (item);
+                       continue;
+               }
+
                /* created_msg_ids are items other than generic item. We fetch them
                 * separately since the property sets vary */
                /* FIXME: Do we need to handle any other item types
diff --git a/src/camel/camel-ews-utils.c b/src/camel/camel-ews-utils.c
index ab1bf1e..c6996fd 100644
--- a/src/camel/camel-ews-utils.c
+++ b/src/camel/camel-ews-utils.c
@@ -762,8 +762,14 @@ camel_ews_utils_sync_updated_items (CamelEwsFolder *ews_folder,
                }
 
                id = e_ews_item_get_id (item);
-               mi = (CamelEwsMessageInfo *)
-                       camel_folder_summary_get (folder->summary, id->id);
+               if (!id) {
+                       g_warning ("%s: Missing ItemId for item type %d (subject:%s)", G_STRFUNC, 
e_ews_item_get_item_type (item),
+                               e_ews_item_get_subject (item) ? e_ews_item_get_subject (item) : "???");
+                       g_object_unref (item);
+                       continue;
+               }
+
+               mi = (CamelEwsMessageInfo *) camel_folder_summary_get (folder->summary, id->id);
                if (mi) {
                        guint32 server_flags;
                        gboolean changed, was_changed;
@@ -842,8 +848,14 @@ camel_ews_utils_sync_created_items (CamelEwsFolder *ews_folder,
                }
 
                id = e_ews_item_get_id (item);
-               mi = (CamelEwsMessageInfo *)
-                       camel_folder_summary_get (folder->summary, id->id);
+               if (!id) {
+                       g_warning ("%s: Missing ItemId for item type %d (subject:%s)", G_STRFUNC, 
e_ews_item_get_item_type (item),
+                               e_ews_item_get_subject (item) ? e_ews_item_get_subject (item) : "???");
+                       g_object_unref (item);
+                       continue;
+               }
+
+               mi = (CamelEwsMessageInfo *) camel_folder_summary_get (folder->summary, id->id);
                if (mi) {
                        camel_message_info_unref (mi);
                        g_object_unref (item);


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