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.
This commit is contained in:
Tim-Philipp Müller 2009-06-16 08:43:53 +01:00
parent 8624aaa415
commit 470e561216
2 changed files with 19 additions and 3 deletions

View file

@ -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);

View file

@ -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);
}