From 6436437d836badb1f01f71cf039fa65e4a3a2023 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Tue, 27 Mar 2018 10:25:46 +0200 Subject: [PATCH] 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 --- gst/gstinfo.c | 15 --------------- tests/check/gst/gstinfo.c | 9 +++++++-- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/gst/gstinfo.c b/gst/gstinfo.c index b1d86f0..1556684 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -1691,18 +1691,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) @@ -1735,9 +1723,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; } diff --git a/tests/check/gst/gstinfo.c b/tests/check/gst/gstinfo.c index 7ebd967..78f8b5a 100644 --- a/tests/check/gst/gstinfo.c +++ b/tests/check/gst/gstinfo.c @@ -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); } -- 2.7.4