[glib] Handle NULL string properties in bindings
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Handle NULL string properties in bindings
- Date: Wed, 21 Apr 2010 18:51:10 +0000 (UTC)
commit 585a37f37455e1b91029db6c40b3a0e2932e0604
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Apr 21 14:47:32 2010 -0400
Handle NULL string properties in bindings
Admittely, we just handle them by failing the conversion...
gio/gsettings-mapping.c | 4 +++-
gio/gsettings.c | 6 +++---
gio/tests/gsettings.c | 1 -
3 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gio/gsettings-mapping.c b/gio/gsettings-mapping.c
index bdd2c9c..0290f6f 100644
--- a/gio/gsettings-mapping.c
+++ b/gio/gsettings-mapping.c
@@ -365,7 +365,9 @@ g_settings_set_mapping (const GValue *value,
else if (G_VALUE_HOLDS_STRING (value))
{
- if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING))
+ if (g_value_get_string (value) == NULL)
+ return NULL;
+ else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING))
return g_variant_new_string (g_value_get_string (value));
else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_OBJECT_PATH))
return g_variant_new_object_path (g_value_get_string (value));
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 26c7515..210a73c 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -1233,9 +1233,9 @@ g_settings_binding_property_changed (GObject *object,
* The binding uses the default GIO mapping functions to map
* between the settings and property values. These functions
* handle booleans, numeric types and string types in a
- * straightforward way. Use g_settings_bind_with_mapping()
- * if you need a custom mapping, or map between types that
- * are not supported by the default mapping functions.
+ * straightforward way. Use g_settings_bind_with_mapping() if
+ * you need a custom mapping, or map between types that are not
+ * supported by the default mapping functions.
*
* Unless the @flags include %G_SETTINGS_BIND_NO_SENSITIVITY, this
* function also establishes a binding between the writability of
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index d04a052..484efac 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -672,7 +672,6 @@ G_DEFINE_TYPE (TestObject, test_object, G_TYPE_OBJECT)
static void
test_object_init (TestObject *object)
{
- object->no_write_prop = "";
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]