[grilo] core: Fixed incorrect filtering of writable and supported keys. Bug was introduced in commit c592a85



commit bcdd81f60eda1e0a9231abef5a2e8891f8afb569
Author: Iago Toral Quiroga <itoral igalia com>
Date:   Tue Nov 30 13:09:39 2010 +0100

    core: Fixed incorrect filtering of writable and supported keys.
    Bug was introduced in commit c592a85afc7c8538d91bb47b16a54c9dce8d5f46.

 src/grl-metadata-source.c |   48 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/src/grl-metadata-source.c b/src/grl-metadata-source.c
index 6828c88..33845b1 100644
--- a/src/grl-metadata-source.c
+++ b/src/grl-metadata-source.c
@@ -518,13 +518,6 @@ filter_key_list (GrlMetadataSource *source,
   gboolean got_match;
   GrlKeyID filtered_key;
 
-  if (!source_keys) {
-    if (return_filtered)
-      filtered_keys = *keys_to_filter;
-    *keys_to_filter = NULL;
-    goto end_func;
-  }
-
   iter_source_keys = (GList *) source_keys;
   while (iter_source_keys) {
     got_match = FALSE;
@@ -778,12 +771,30 @@ grl_metadata_source_filter_supported (GrlMetadataSource *source,
                                       gboolean return_filtered)
 {
   const GList *supported_keys;
+  GList *tmp, *filtered;
 
   g_return_val_if_fail (GRL_IS_METADATA_SOURCE (source), NULL);
 
   supported_keys = grl_metadata_source_supported_keys (source);
 
-  return filter_key_list (source, keys, return_filtered, supported_keys);
+  /*
+   * filter_key_list removes keys found in supported_keys from
+   * keys and returns the removed keys. However, we want to do
+   * exactly the opposite: keep the found supported_keys in keys
+   * and return the list of keys that are non supported.
+   */
+
+  filtered = filter_key_list (source, keys, TRUE, supported_keys);
+
+  tmp = *keys;
+  *keys = filtered;
+
+  if (return_filtered) {
+    return tmp;
+  } else {
+    g_list_free (tmp);
+    return NULL;
+  }
 }
 
 /**
@@ -836,13 +847,32 @@ grl_metadata_source_filter_writable (GrlMetadataSource *source,
 				     gboolean return_filtered)
 {
   const GList *writable_keys;
+  GList *filtered;
+  GList *tmp;
 
   g_return_val_if_fail (GRL_IS_METADATA_SOURCE (source), NULL);
   g_return_val_if_fail (keys != NULL, NULL);
 
   writable_keys = grl_metadata_source_writable_keys (source);
 
-  return filter_key_list (source, keys, return_filtered, writable_keys);
+  /*
+   * filter_key_list removes keys found in writable_keys from
+   * keys and returns the removed keys. However, we want to do
+   * exactly the opposite: keep the found writable_keys in keys
+   * and return the list of keys that are non writable.
+   */
+
+  filtered = filter_key_list (source, keys, TRUE, writable_keys);
+
+  tmp = *keys;
+  *keys = filtered;
+
+  if (return_filtered) {
+    return tmp;
+  } else {
+    g_list_free (tmp);
+    return NULL;
+  }
 }
 
 void



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