[totem/wip/hadess/missing-video-plugin-but-subs: 2/2] backend: Fix duplicated missing codecs



commit 1cbce5424df8353f0f4f1ca077cd608da7cdf69c
Author: Bastien Nocera <hadess hadess net>
Date:   Mon May 6 14:14:32 2019 +0200

    backend: Fix duplicated missing codecs
    
    If there are multiple tracks with the same missing codec, only show a
    single line for that codec, rather than as many as the number of tracks
    from which it's missing.

 src/backend/bacon-video-widget.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/backend/bacon-video-widget.c b/src/backend/bacon-video-widget.c
index ea9602479..89674a9e8 100644
--- a/src/backend/bacon-video-widget.c
+++ b/src/backend/bacon-video-widget.c
@@ -345,12 +345,22 @@ static gchar **
 bvw_get_missing_plugins_foo (const GList * missing_plugins, MsgToStrFunc func)
 {
   GPtrArray *arr = g_ptr_array_new ();
+  GHashTable *ht;
 
+  ht = g_hash_table_new (g_str_hash, g_str_equal);
   while (missing_plugins != NULL) {
-    g_ptr_array_add (arr, func (GST_MESSAGE (missing_plugins->data)));
+    char *tmp;
+    tmp = func (GST_MESSAGE (missing_plugins->data));
+    if (!g_hash_table_lookup (ht, tmp)) {
+      g_ptr_array_add (arr, tmp);
+      g_hash_table_insert (ht, tmp, GINT_TO_POINTER (1));
+    } else {
+      g_free (tmp);
+    }
     missing_plugins = missing_plugins->next;
   }
   g_ptr_array_add (arr, NULL);
+  g_hash_table_destroy (ht);
   return (gchar **) g_ptr_array_free (arr, FALSE);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]