[grilo] core: Allow removing metadata keys in GrlData
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] core: Allow removing metadata keys in GrlData
- Date: Wed, 10 Dec 2014 13:17:48 +0000 (UTC)
commit 32275f8daace57eaea1899ad534244091e05e0a9
Author: Bastien Nocera <hadess hadess net>
Date: Mon Dec 8 17:49:02 2014 +0100
core: Allow removing metadata keys in GrlData
https://bugzilla.gnome.org/show_bug.cgi?id=741207
src/data/grl-data.c | 6 ++----
src/data/grl-related-keys.c | 12 +++++++-----
2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/data/grl-data.c b/src/data/grl-data.c
index b453694..9f9aba2 100644
--- a/src/data/grl-data.c
+++ b/src/data/grl-data.c
@@ -194,10 +194,6 @@ grl_data_set (GrlData *data, GrlKeyID key, const GValue *value)
g_return_if_fail (GRL_IS_DATA (data));
g_return_if_fail (key);
- if (!value) {
- return;
- }
-
/* Get the right set of related keys */
if (grl_data_length (data, key) > 0) {
relkeys = grl_data_get_related_keys (data, key, 0);
@@ -240,6 +236,8 @@ grl_data_set_string (GrlData *data,
g_value_set_string (&value, strvalue);
grl_data_set (data, key, &value);
g_value_unset (&value);
+ } else {
+ grl_data_set (data, key, NULL);
}
}
diff --git a/src/data/grl-related-keys.c b/src/data/grl-related-keys.c
index 2bde3c0..feb0a7f 100644
--- a/src/data/grl-related-keys.c
+++ b/src/data/grl-related-keys.c
@@ -242,18 +242,20 @@ grl_related_keys_set (GrlRelatedKeys *relkeys,
g_return_if_fail (GRL_IS_RELATED_KEYS (relkeys));
g_return_if_fail (key);
- if (!value) {
- return;
- }
-
/* Dup value */
- if (G_VALUE_TYPE (value) != GRL_METADATA_KEY_GET_TYPE (key)) {
+ if (value != NULL &&
+ G_VALUE_TYPE (value) != GRL_METADATA_KEY_GET_TYPE (key)) {
GRL_WARNING ("value has type %s, but expected %s",
g_type_name (G_VALUE_TYPE (value)),
g_type_name (GRL_METADATA_KEY_GET_TYPE (key)));
return;
}
+ if (!value) {
+ g_hash_table_remove (relkeys->priv->data, GRLKEYID_TO_POINTER (key));
+ return;
+ }
+
copy = g_new0 (GValue, 1);
g_value_init (copy, G_VALUE_TYPE (value));
g_value_copy (value, copy);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]