[libgdata] contacts: Set out parameters in error conditions



commit 68b13c9ca480da464780f308e60cb5f4cfd8a60e
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Aug 20 17:41:29 2011 +0100

    contacts: Set out parameters in error conditions
    
    The out parameters of gdata_contacts_contact_get_photo_finish() were
    previously being left uninitialised if an error was returned, which isn't
    very friendly. They now return well-defined values, and the documentation's
    been updated appropriately.

 gdata/services/contacts/gdata-contacts-contact.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gdata/services/contacts/gdata-contacts-contact.c b/gdata/services/contacts/gdata-contacts-contact.c
index 1aa63dc..78cb76c 100644
--- a/gdata/services/contacts/gdata-contacts-contact.c
+++ b/gdata/services/contacts/gdata-contacts-contact.c
@@ -3220,7 +3220,8 @@ gdata_contacts_contact_get_photo_async (GDataContactsContact *self, GDataContact
  * Finishes an asynchronous contact photo retrieval operation started with gdata_contacts_contact_get_photo_async(). If the contact doesn't have a
  * photo (i.e. gdata_contacts_contact_get_photo_etag() returns %NULL), %NULL is returned, but no error is set in @error.
  *
- * If there is an error getting the photo, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned.
+ * If there is an error getting the photo, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned. @length will be set to
+ * <code class="literal">0</code> and @content_type will be set to %NULL.
  *
  * Return value: the image data, or %NULL; free with g_free()
  *
@@ -3240,8 +3241,16 @@ gdata_contacts_contact_get_photo_finish (GDataContactsContact *self, GAsyncResul
 
 	g_warn_if_fail (g_simple_async_result_get_source_tag (result) == gdata_contacts_contact_get_photo_async);
 
-	if (g_simple_async_result_propagate_error (result, error) == TRUE)
+	if (g_simple_async_result_propagate_error (result, error) == TRUE) {
+		/* Error */
+		*length = 0;
+
+		if (content_type != NULL) {
+			*content_type = NULL;
+		}
+
 		return NULL;
+	}
 
 	/* Return the photo (steal the data from the PhotoData struct so we don't have to copy it again) */
 	data = g_simple_async_result_get_op_res_gpointer (result);



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