]> saetta.ns0.it Git - zakform/ini/commitdiff
Bug in ZakFormElement::unformat: returns null when value is null. master
authorAndrea Zagli <azagli@libero.it>
Sat, 27 May 2017 09:26:51 +0000 (11:26 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 27 May 2017 09:26:51 +0000 (11:26 +0200)
src/form.c

index 86d2daaeb0638e6618457b9de829c2e404d37e1a..6d748eb7fd139e5658a38ffb749579a025c9b25b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2016-2017 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -32,13 +32,13 @@ static void zak_form_ini_provider_init (ZakFormIniProvider *zak_form_ini_provide
 static void zak_form_iprovider_interface_init (ZakFormIProviderInterface *iface);
 
 static void zak_form_ini_provider_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
+                                                guint property_id,
+                                                const GValue *value,
+                                                GParamSpec *pspec);
 static void zak_form_ini_provider_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
+                                                guint property_id,
+                                                GValue *value,
+                                                GParamSpec *pspec);
 
 static void zak_form_ini_provider_dispose (GObject *gobject);
 static void zak_form_ini_provider_finalize (GObject *gobject);
@@ -62,9 +62,9 @@ struct _ZakFormIniProvider
 };
 
 G_DEFINE_TYPE_WITH_CODE (ZakFormIniProvider, zak_form_ini_provider, G_TYPE_OBJECT,
-                                                G_ADD_PRIVATE (ZakFormIniProvider)
-                                                G_IMPLEMENT_INTERFACE (ZAK_FORM_TYPE_IPROVIDER,
-                                                                                               zak_form_iprovider_interface_init))
+                         G_ADD_PRIVATE (ZakFormIniProvider)
+                         G_IMPLEMENT_INTERFACE (ZAK_FORM_TYPE_IPROVIDER,
+                                                zak_form_iprovider_interface_init))
 
 static void
 zak_form_ini_provider_class_init (ZakFormIniProviderClass *class)
@@ -158,8 +158,8 @@ ZakFormIniProvider
        if (!g_key_file_load_from_file (kfile, filename, G_KEY_FILE_NONE, &error))
                {
                        g_warning ("Unable to open ini file: «%s»\n. %s",
-                                          filename,
-                                          error != NULL && error->message != NULL ? error->message : "No details.");
+                                  filename,
+                                  error != NULL && error->message != NULL ? error->message : "No details.");
                        return NULL;
                }
        zak_form_ini_provider = zak_form_ini_provider_new_from_gkeyfile (kfile, filename);
@@ -170,9 +170,9 @@ ZakFormIniProvider
 /* PRIVATE */
 static void
 zak_form_ini_provider_set_property (GObject *object,
-                   guint property_id,
-                   const GValue *value,
-                   GParamSpec *pspec)
+                                    guint property_id,
+                                    const GValue *value,
+                                    GParamSpec *pspec)
 {
        ZakFormIniProvider *zak_form_ini_provider = (ZakFormIniProvider *)object;
        ZakFormIniProviderPrivate *priv = zak_form_ini_provider_get_instance_private (zak_form_ini_provider);
@@ -187,9 +187,9 @@ zak_form_ini_provider_set_property (GObject *object,
 
 static void
 zak_form_ini_provider_get_property (GObject *object,
-                   guint property_id,
-                   GValue *value,
-                   GParamSpec *pspec)
+                                    guint property_id,
+                                    GValue *value,
+                                    GParamSpec *pspec)
 {
        ZakFormIniProvider *zak_form_ini_provider = (ZakFormIniProvider *)object;
        ZakFormIniProviderPrivate *priv = zak_form_ini_provider_get_instance_private (zak_form_ini_provider);
@@ -242,7 +242,7 @@ static gchar
 
                        if (zak_form_element_get_is_key (element))
                                {
-                                       value = zak_form_element_unformat (element, NULL);
+                                       value = zak_form_element_unformat (element, zak_form_element_get_value (element));
                                        g_string_append_printf (key, "|%s", value);
                                        g_free (value);
                                }
@@ -318,19 +318,19 @@ zak_form_ini_provider_insert (ZakFormIProvider *provider, GPtrArray *elements)
                        ZakFormElement *element = (ZakFormElement *)g_ptr_array_index (elements, i);
                        if (zak_form_element_get_to_save (element))
                                {
-                                       value = zak_form_element_unformat (element, NULL);
+                                       value = zak_form_element_unformat (element, zak_form_element_get_value (element));
 
                                        g_key_file_set_string (priv->kfile, group,
-                                                                                  zak_form_element_get_name (element),
-                                                                                  value);
+                                                              zak_form_element_get_name (element),
+                                                              value);
 
                                        error = NULL;
                                        if (!g_key_file_save_to_file (priv->kfile, priv->filename, &error)
                                                || error != NULL)
                                                {
                                                        g_warning ("Unable to write to file «%s»: %s.",
-                                                                          priv->filename,
-                                                                          error != NULL && error->message != NULL ? error->message : "no details");
+                                                                  priv->filename,
+                                                                  error != NULL && error->message != NULL ? error->message : "no details");
                                                }
 
                                        g_free (value);
@@ -372,16 +372,16 @@ zak_form_ini_provider_delete (ZakFormIProvider *provider, GPtrArray *elements)
                                {
                                        error = NULL;
                                        g_key_file_remove_key (priv->kfile, group,
-                                                                                  zak_form_element_get_name (element),
-                                                                                  &error);
+                                                              zak_form_element_get_name (element),
+                                                              &error);
 
                                        error = NULL;
                                        if (!g_key_file_save_to_file (priv->kfile, priv->filename, &error)
                                                || error != NULL)
                                                {
                                                        g_warning ("Unable to write to file «%s»: %s.",
-                                                                          priv->filename,
-                                                                          error != NULL && error->message != NULL ? error->message : "no details");
+                                                                  priv->filename,
+                                                                  error != NULL && error->message != NULL ? error->message : "no details");
                                                }
                                }
                }