gstinfo: fix debug levels being applied in the wrong order

Remove unneeded reapplication of patterns. Besides being
superfluous (gst_debug_reset_threshold already applies
patterns) it was also wrong and didn't stop checking patterns
after the first match (broken in 67e9d139).

Also fix up unit test which checked for the wrong order.

https://bugzilla.gnome.org/show_bug.cgi?id=794717
This commit is contained in:
Jan Alexander Steffens (heftig) 2018-03-27 10:25:46 +02:00 committed by Tim-Philipp Müller
parent 1e3272ee91
commit 0b293cad89
2 changed files with 7 additions and 17 deletions

View file

@ -1689,18 +1689,6 @@ gst_debug_unset_threshold_for_name (const gchar * name)
gst_debug_reset_all_thresholds ();
}
static void
gst_debug_apply_patterns_to_category (GstDebugCategory * cat)
{
GSList *l;
g_mutex_lock (&__level_name_mutex);
for (l = __level_name; l != NULL; l = l->next) {
for_each_threshold_by_entry (cat, (LevelNameEntry *) l->data);
}
g_mutex_unlock (&__level_name_mutex);
}
GstDebugCategory *
_gst_debug_category_new (const gchar * name, guint color,
const gchar * description)
@ -1733,9 +1721,6 @@ _gst_debug_category_new (const gchar * name, guint color,
}
g_mutex_unlock (&__cat_mutex);
/* ensure the filter is applied to categories registered after _debug_init */
gst_debug_apply_patterns_to_category (cat);
return cat;
}

View file

@ -440,7 +440,8 @@ GST_START_TEST (info_post_gst_init_category_registration)
/* Note: before the fixes this wouldn't work to trigger the problem because
* only a pattern set via GST_DEBUG before gst_init would be picked up
* (another bug) */
gst_debug_set_threshold_from_string ("*a*b:6,*c:3,d*:2,xyz*:9,ax:1", TRUE);
gst_debug_set_threshold_from_string ("*a*b:6,*b*0:6,*c:3,d*:2,xyz*:9,ax:1",
TRUE);
fail_unless_equals_int (GST_LEVEL_DEFAULT,
gst_debug_get_default_threshold ());
@ -471,8 +472,12 @@ GST_START_TEST (info_post_gst_init_category_registration)
/* *c:3 */
fail_unless_equals_int (gst_debug_category_get_threshold (cats[0x4c]),
GST_LEVEL_FIXME);
/* *a*b:6 */
/* *a*b:6 and d*:2, but d*:2 takes priority here as cat name is "dog-a1b"
* and order matters: items listed later override earlier ones. */
fail_unless_equals_int (gst_debug_category_get_threshold (cats[0xa1b]),
GST_LEVEL_WARNING);
/* *a*0:6 */
fail_unless_equals_int (gst_debug_category_get_threshold (cats[0xb10]),
GST_LEVEL_LOG);
}