Bug #633177 - Avoid runtime warnings from CamelFolder::cmp_uids() overrides
authorMilan Crha <mcrha@redhat.com>
Mon, 10 Mar 2014 14:04:53 +0000 (15:04 +0100)
committerMilan Crha <mcrha@redhat.com>
Mon, 10 Mar 2014 14:04:53 +0000 (15:04 +0100)
camel/providers/local/camel-maildir-folder.c
camel/providers/local/camel-mbox-folder.c

index 2448d75..d8414f6 100644 (file)
@@ -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);
index 16e589a..c25b2de 100644 (file)
@@ -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;