From 1a759d0f9143bbb46c55bec2e67ed4f6185ae688 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 27 May 2017 11:26:51 +0200 Subject: [PATCH] Bug in ZakFormElement::unformat: returns null when value is null. --- src/form.c | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/form.c b/src/form.c index 86d2daa..6d748eb 100644 --- a/src/form.c +++ b/src/form.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Andrea Zagli + * Copyright (C) 2016-2017 Andrea Zagli * * 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"); } } } -- 2.49.0