From 470e5612166777156ca3de26efb43db5aef81dd8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 16 Jun 2009 08:43:53 +0100 Subject: [PATCH] gstxml: fix (de)serialisation of properties of type GstStructure souphttpsrc has a property of type GstStructure, which causes an assertion when serialising it to xml. Fixes #585137. --- gst/gstelement.c | 9 ++++++++- gst/gstutils.c | 13 +++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gst/gstelement.c b/gst/gstelement.c index af83fce..4fc095b 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -89,6 +89,7 @@ #include "gstevent.h" #include "gstutils.h" #include "gstinfo.h" +#include "gstvalue.h" #include "gst-i18n-lib.h" /* Element signals and args */ @@ -2958,7 +2959,13 @@ gst_element_save_thyself (GstObject * object, xmlNodePtr parent) else if (G_IS_PARAM_SPEC_INT64 (spec)) contents = g_strdup_printf ("%" G_GINT64_FORMAT, g_value_get_int64 (&value)); - else + else if (GST_VALUE_HOLDS_STRUCTURE (&value)) { + if (g_value_get_boxed (&value) != NULL) { + contents = g_strdup_value_contents (&value); + } else { + contents = g_strdup ("NULL"); + } + } else contents = g_strdup_value_contents (&value); xmlNewChild (param, NULL, (xmlChar *) "value", (xmlChar *) contents); diff --git a/gst/gstutils.c b/gst/gstutils.c index 1b74d62..0f49340 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -140,16 +140,25 @@ gst_util_set_object_arg (GObject * object, const gchar * name, value_type = G_PARAM_SPEC_VALUE_TYPE (pspec); - GST_DEBUG ("pspec->flags is %d, pspec->value_type is %d", - pspec->flags, (gint) value_type); + GST_DEBUG ("pspec->flags is %d, pspec->value_type is %s", + pspec->flags, g_type_name (value_type)); if (!(pspec->flags & G_PARAM_WRITABLE)) return; g_value_init (&v, value_type); + + /* special case for element <-> xml (de)serialisation */ + if (GST_VALUE_HOLDS_STRUCTURE (&v) && strcmp (value, "NULL") == 0) { + g_value_set_boxed (&v, NULL); + goto done; + } + if (!gst_value_deserialize (&v, value)) return; +done: + g_object_set_property (object, pspec->name, &v); g_value_unset (&v); } -- 2.7.4