Setting NULL values to grl_data_set_string



This will result in a gvalue with a string inside it, but talking to
Juan, we agreed that it was better to contain a NULL GValue instead, and
that's this patch is for.

-- 
Xabier Rodríguez Calvar
Enxeñeiro en Informática
IGALIA http://www.igalia.com
From 7de92e5f80405e57b2c9534da410f4adddb7db61 Mon Sep 17 00:00:00 2001
From: Xabier Rodriguez Calvar <xrcalvar igalia com>
Date: Fri, 23 Apr 2010 17:16:40 +0200
Subject: [PATCH] [core] Create null GValue when setting null to grl_data_set_string

---
 src/data/grl-data.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/data/grl-data.c b/src/data/grl-data.c
index d6fa8dc..92a6b53 100644
--- a/src/data/grl-data.c
+++ b/src/data/grl-data.c
@@ -220,11 +220,15 @@ grl_data_set_string (GrlData *data,
                      GrlKeyID key,
                      const gchar *strvalue)
 {
-  GValue value = { 0 };
-  g_value_init (&value, G_TYPE_STRING);
-  g_value_set_string (&value, strvalue);
-  grl_data_set (data, key, &value);
-  g_value_unset (&value);
+  if (strvalue) {
+    GValue value = { 0 };
+    g_value_init (&value, G_TYPE_STRING);
+    g_value_set_string (&value, strvalue);
+    grl_data_set (data, key, &value);
+    g_value_unset (&value);
+  } else {
+    grl_data_set (data, key, NULL);
+  }
 }
 
 /**
-- 
1.7.0

Attachment: signature.asc
Description: Esta =?ISO-8859-1?Q?=E9?= unha parte de mensaxe asinada dixitalmente



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