[gom] gom: Allow the empty string as an ID



commit d2e01eda68bd9ffbd30c68151760e3346c53de68
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Sep 26 20:52:57 2014 +0200

    gom: Allow the empty string as an ID
    
    gjs doesn't allow null values for string properties, so work-around that
    by allowing '0' as a value.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728301

 gom/gom-resource.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/gom/gom-resource.c b/gom/gom-resource.c
index ccec0d7..1a46084 100644
--- a/gom/gom-resource.c
+++ b/gom/gom-resource.c
@@ -71,7 +71,8 @@ gom_resource_class_set_primary_key (GomResourceClass *resource_class,
 
    /* Same check as in has_primary_key() */
    value = g_param_spec_get_default_value (pspec);
-   if (value->data[0].v_pointer) {
+   if (value->data[0].v_pointer &&
+       *((char *) value->data[0].v_pointer) != '\0') {
       g_warning("Property for primary key '%s' (class %s) has a non-NULL/non-zero default value. This will 
not work as expected.",
                 primary_key, G_OBJECT_CLASS_NAME(resource_class));
       return;


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