[evolution-data-server] Bug #633177 - Avoid runtime warnings from CamelFolder::cmp_uids() overrides



commit 741868239afc914b91e220f7f32e76a05bef4e3a
Author: Milan Crha <mcrha redhat com>
Date:   Mon Mar 10 15:04:53 2014 +0100

    Bug #633177 - Avoid runtime warnings from CamelFolder::cmp_uids() overrides

 camel/providers/local/camel-maildir-folder.c |   15 +++++++++++++--
 camel/providers/local/camel-mbox-folder.c    |   15 +++++++++++++--
 2 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index 2448d75..d8414f6 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -55,8 +55,19 @@ maildir_folder_cmp_uids (CamelFolder *folder,
        a = camel_folder_summary_get (folder->summary, uid1);
        b = camel_folder_summary_get (folder->summary, uid2);
 
-       g_return_val_if_fail (a != NULL, 0);
-       g_return_val_if_fail (b != NULL, 0);
+       if (!a || !b) {
+               /* It's not a problem when one of the messages is not in the summary */
+               if (a)
+                       camel_message_info_unref (a);
+               if (b)
+                       camel_message_info_unref (b);
+
+               if (a == b)
+                       return 0;
+               if (!a)
+                       return -1;
+               return 1;
+       }
 
        tma = camel_message_info_date_received (a);
        tmb = camel_message_info_date_received (b);
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index 16e589a..c25b2de 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -60,8 +60,19 @@ mbox_folder_cmp_uids (CamelFolder *folder,
        a = (CamelMboxMessageInfo *) camel_folder_summary_get (folder->summary, uid1);
        b = (CamelMboxMessageInfo *) camel_folder_summary_get (folder->summary, uid2);
 
-       g_return_val_if_fail (a != NULL, 0);
-       g_return_val_if_fail (b != NULL, 0);
+       if (!a || !b) {
+               /* It's not a problem when one of the messages is not in the summary */
+               if (a)
+                       camel_message_info_unref (a);
+               if (b)
+                       camel_message_info_unref (b);
+
+               if (a == b)
+                       return 0;
+               if (!a)
+                       return -1;
+               return 1;
+       }
 
        res = a->frompos < b->frompos ? -1 : a->frompos == b->frompos ? 0 : 1;
 


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