[grilo] Check that value has expected type defined in key specification
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] Check that value has expected type defined in key specification
- Date: Wed, 9 Jun 2010 11:52:09 +0000 (UTC)
commit e6a4ed06158a3948a600889a9ce999e09a21d34a
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Mon Jun 7 17:01:19 2010 +0200
Check that value has expected type defined in key specification
src/data/grl-data.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/data/grl-data.c b/src/data/grl-data.c
index 7a0eac0..40912ea 100644
--- a/src/data/grl-data.c
+++ b/src/data/grl-data.c
@@ -200,12 +200,18 @@ grl_data_set (GrlData *data, GrlKeyID key, const GValue *value)
g_hash_table_lookup (data->priv->data, key) == NULL) {
/* Dup value */
if (value) {
- copy = g_new0 (GValue, 1);
- g_value_init (copy, G_VALUE_TYPE (value));
- g_value_copy (value, copy);
+ if (G_VALUE_TYPE (value) == GRL_METADATA_KEY_GET_TYPE (key)) {
+ copy = g_new0 (GValue, 1);
+ g_value_init (copy, G_VALUE_TYPE (value));
+ g_value_copy (value, copy);
+ } else {
+ g_warning ("value has type %s, but expected %s",
+ g_type_name (G_VALUE_TYPE (value)),
+ g_type_name (GRL_METADATA_KEY_GET_TYPE (key)));
+ }
}
- if (g_param_value_validate (key, copy)) {
+ if (copy && g_param_value_validate (key, copy)) {
g_warning ("'%s' value invalid, adjusting",
GRL_METADATA_KEY_GET_NAME (key));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]