info: Make sure the same category is not added twice
authorOlivier Crête <olivier.crete@collabora.com>
Wed, 4 Dec 2013 22:35:18 +0000 (17:35 -0500)
committerOlivier Crête <olivier.crete@collabora.com>
Wed, 4 Dec 2013 22:35:18 +0000 (17:35 -0500)
gst/gstinfo.c

index ab454b5..c9d8325 100644 (file)
@@ -248,6 +248,9 @@ LevelNameEntry;
 static GMutex __cat_mutex;
 static GSList *__categories = NULL;
 
+static GstDebugCategory *_gst_debug_get_category_locked (const gchar * name);
+
+
 /* all registered debug handlers */
 typedef struct
 {
@@ -1523,7 +1526,13 @@ _gst_debug_category_new (const gchar * name, guint color,
 
   /* add to category list */
   g_mutex_lock (&__cat_mutex);
-  __categories = g_slist_prepend (__categories, cat);
+  if (_gst_debug_get_category_locked (name)) {
+    g_free ((gpointer) cat->name);
+    g_free ((gpointer) cat->description);
+    g_slice_free (GstDebugCategory, cat);
+  } else {
+    __categories = g_slist_prepend (__categories, cat);
+  }
   g_mutex_unlock (&__cat_mutex);
 
   return cat;