[libgdata] [core] Fix reference problems and filter out duplicate namespaces
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Subject: [libgdata] [core] Fix reference problems and filter out duplicate namespaces
- Date: Sun, 17 May 2009 07:54:39 -0400 (EDT)
commit 164c9b9fbd8c9bf35427e088973b0b79a90bca3e
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun May 17 12:54:00 2009 +0100
[core] Fix reference problems and filter out duplicate namespaces
Fixes reference problems in the error case of gdata_service_delete_entry,
and ensures that the extra_namespaces hash table doesn't contain any
namespaces which are duplicates of the defined set (when building XML).
---
gdata/gdata-entry.c | 11 +++++++++++
gdata/gdata-service.c | 11 ++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/gdata/gdata-entry.c b/gdata/gdata-entry.c
index 53947cc..337b1ce 100644
--- a/gdata/gdata-entry.c
+++ b/gdata/gdata-entry.c
@@ -833,6 +833,14 @@ build_namespaces_cb (gchar *prefix, gchar *href, GString *output)
g_string_append_printf (output, " xmlns:%s='%s'", prefix, href);
}
+static gboolean
+filter_namespaces_cb (gchar *prefix, gchar *href, GHashTable *canonical_namespaces)
+{
+ if (g_hash_table_lookup (canonical_namespaces, prefix) != NULL)
+ return TRUE;
+ return FALSE;
+}
+
/**
* gdata_entry_get_xml:
* @self: a #GDataEntry
@@ -858,6 +866,9 @@ gdata_entry_get_xml (GDataEntry *self)
namespaces = g_hash_table_new (g_str_hash, g_str_equal);
klass->get_namespaces (self, namespaces);
+ /* Remove any duplicate extra namespaces */
+ g_hash_table_foreach_remove (self->priv->extra_namespaces, (GHRFunc) filter_namespaces_cb, namespaces);
+
/* Build up the namespace list */
xml_string = g_string_new ("<entry xmlns='http://www.w3.org/2005/Atom'");
g_hash_table_foreach (namespaces, (GHFunc) build_namespaces_cb, xml_string);
diff --git a/gdata/gdata-service.c b/gdata/gdata-service.c
index 68b95fb..e31c4f2 100644
--- a/gdata/gdata-service.c
+++ b/gdata/gdata-service.c
@@ -1543,13 +1543,16 @@ gdata_service_delete_entry (GDataService *self, GDataEntry *entry, GCancellable
/* Send the message */
status = _gdata_service_send_message (self, message, error);
- g_object_unref (message);
- if (status == SOUP_STATUS_NONE)
+ if (status == SOUP_STATUS_NONE) {
+ g_object_unref (message);
return FALSE;
+ }
/* Check for cancellation */
- if (g_cancellable_set_error_if_cancelled (cancellable, error) == TRUE)
+ if (g_cancellable_set_error_if_cancelled (cancellable, error) == TRUE) {
+ g_object_unref (message);
return FALSE;
+ }
if (status != 200) {
/* Error */
@@ -1560,6 +1563,8 @@ gdata_service_delete_entry (GDataService *self, GDataEntry *entry, GCancellable
return FALSE;
}
+ g_object_unref (message);
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]