g_strdup_value_contents(): dump GStrv more usefully

Previously, dumping a GValue holding a GStrv just yielded "((GStrv *)
0xDEADBEEF)". I think it'd be more useful to dump a Python list-style
representation of the GStrv's contents, if it's not NULL.

Fixes: <https://bugzilla.gnome.org/show_bug.cgi?id=629192>
This commit is contained in:
Will Thompson 2010-09-09 17:24:00 +01:00
parent cb2ddac7a2
commit ba17efc396

View File

@ -1339,6 +1339,25 @@ g_strdup_value_contents (const GValue *value)
contents = g_strdup_printf ("((%s*) %p)", G_OBJECT_TYPE_NAME (p), p);
else if (G_VALUE_HOLDS_PARAM (value))
contents = g_strdup_printf ("((%s*) %p)", G_PARAM_SPEC_TYPE_NAME (p), p);
else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
{
GStrv strv = g_value_get_boxed (value);
GString *tmp = g_string_new ("[");
while (*strv != NULL)
{
gchar *escaped = g_strescape (*strv, NULL);
g_string_append_printf (tmp, "\"%s\"", escaped);
g_free (escaped);
if (*++strv != NULL)
g_string_append (tmp, ", ");
}
g_string_append (tmp, "]");
contents = g_string_free (tmp, FALSE);
}
else if (G_VALUE_HOLDS_BOXED (value))
contents = g_strdup_printf ("((%s*) %p)", g_type_name (G_VALUE_TYPE (value)), p);
else if (G_VALUE_HOLDS_POINTER (value))