tags: only emit a g_warning() for empty tag strings for git versions

For now, don't show a g_warning() for empty tag strings and NULL
tags with non-git versions; we should wait for the fixes in our
plugin modules to make it into a release before we enable this
unconditionally.
This commit is contained in:
Tim-Philipp Müller 2009-07-16 13:59:07 +01:00
parent 30528726bb
commit 9459a93cb4
2 changed files with 12 additions and 2 deletions

View file

@ -641,6 +641,12 @@ gst_structure_id_new (GQuark name_quark, GQuark field_quark, ...)
return s; return s;
} }
#if GST_VERSION_NANO == 1
#define GIT_G_WARNING g_warning
#else
#define GIT_G_WARNING GST_WARNING
#endif
/* If the structure currently contains a field with the same name, it is /* If the structure currently contains a field with the same name, it is
* replaced with the provided field. Otherwise, the field is added to the * replaced with the provided field. Otherwise, the field is added to the
* structure. The field's value is not deeply copied. * structure. The field's value is not deeply copied.
@ -659,13 +665,13 @@ gst_structure_set_field (GstStructure * structure, GstStructureField * field)
* structs, e.g. error message debug strings */ * structs, e.g. error message debug strings */
if (G_UNLIKELY (IS_TAGLIST (structure) && (s == NULL || *s == '\0'))) { if (G_UNLIKELY (IS_TAGLIST (structure) && (s == NULL || *s == '\0'))) {
if (s == NULL) { if (s == NULL) {
g_warning ("Trying to set NULL string on field '%s' on taglist. " GIT_G_WARNING ("Trying to set NULL string on field '%s' on taglist. "
"Please file a bug.", g_quark_to_string (field->name)); "Please file a bug.", g_quark_to_string (field->name));
g_value_unset (&field->value); g_value_unset (&field->value);
return; return;
} else { } else {
/* empty strings never make sense */ /* empty strings never make sense */
g_warning ("Trying to set empty string on taglist field '%s'. " GIT_G_WARNING ("Trying to set empty string on taglist field '%s'. "
"Please file a bug.", g_quark_to_string (field->name)); "Please file a bug.", g_quark_to_string (field->name));
g_value_unset (&field->value); g_value_unset (&field->value);
return; return;

View file

@ -387,6 +387,10 @@ GST_START_TEST (test_empty_tags)
{ {
GstTagList *tags; GstTagList *tags;
/* only get g_warnings() with git */
if (GST_VERSION_NANO != 1)
return;
tags = gst_tag_list_new (); tags = gst_tag_list_new ();
ASSERT_WARNING (gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, ASSERT_WARNING (gst_tag_list_add (tags, GST_TAG_MERGE_APPEND,
GST_TAG_ARTIST, NULL, NULL)); GST_TAG_ARTIST, NULL, NULL));