[evolution-kolab/ek-wip-porting] CamelKolabIMAPXStore: avoid Camel warning (error not set on failure)



commit 9b7be82127dd386c52245a24bba496acaadbfb2f
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Jul 13 15:40:57 2012 +0200

    CamelKolabIMAPXStore: avoid Camel warning (error not set on failure)
    
    * if kolab_imapx_store_get_folder_info_sync() has no folder
      info to return to the caller (e.g. when no folder matching
      the configured to-care-for-type can be found), this is not
      an error (so we don't set one), but we need to return an
      empty CamelFolderInfo instead of NULL as expected by Camel
    * cleaned up that function so we can release the lock just
      before returning

 src/libekolab/camel-kolab-imapx-store.c |   38 +++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/src/libekolab/camel-kolab-imapx-store.c b/src/libekolab/camel-kolab-imapx-store.c
index 33e209c..2ab10bf 100644
--- a/src/libekolab/camel-kolab-imapx-store.c
+++ b/src/libekolab/camel-kolab-imapx-store.c
@@ -597,24 +597,38 @@ kolab_imapx_store_get_folder_info_sync (CamelStore *self,
 	                                               &tmp_err);
 	if (tmp_err != NULL)
 		goto exit;
-	if (fi == NULL)
-		goto exit;
 
-	k_fi = imapx_store_folder_info_build_restricted (myself,
-	                                                 fi,
-	                                                 cancellable,
-	                                                 &tmp_err);
- exit:
-	if (fi != NULL)
+	if (fi != NULL) {
+		k_fi = imapx_store_folder_info_build_restricted (myself,
+		                                                 fi,
+		                                                 cancellable,
+		                                                 &tmp_err);
 		camel_store_free_folder_info (self, fi);
 
-	g_mutex_unlock (&(priv->kolab_finfo_lock));
+		if (tmp_err != NULL)
+			goto exit;
+	}
 
-	if (tmp_err != NULL) {
-		g_propagate_error (err, tmp_err);
-		return NULL;
+	if (k_fi == NULL) {
+		/* No folder information - returning NULL would
+		 * mean we would have to set an error, but no
+		 * folder info (all folders hidden or no type
+		 * information available) is not technically an
+		 * error here. It can happen, depending on the folder
+		 * type we're supposed to care for. Hence, we're
+		 * returning an empty (but non-NULL) CamelFolderInfo
+		 * in the hopes that the caller will know what to
+		 * do about it (i.e., display nothing).
+		 */
+		k_fi = camel_folder_info_new ();
 	}
 
+ exit:
+	if (tmp_err != NULL)
+		g_propagate_error (err, tmp_err);
+
+	g_mutex_unlock (&(priv->kolab_finfo_lock));
+
 	return k_fi;
 }
 



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