From dbce9eb8b8fcc6a3b90d630e04f4f8cd8e88307b Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Wed, 20 Nov 2013 08:45:20 +0100 Subject: [PATCH] Bugfix: not considered where eq NULL for gdaex_get_new_id in GtkForm::get_sql. --- libgtkform/form.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libgtkform/form.c b/libgtkform/form.c index e6cf1ed..eaacdd1 100644 --- a/libgtkform/form.c +++ b/libgtkform/form.c @@ -2061,7 +2061,8 @@ gchar g_return_val_if_fail (IS_GDAEX (priv->gdaex), NULL); - where = NULL; + key_where = NULL; + if (IS_GTK_FORM_KEY (priv->key) && gtk_form_key_field_is_key (priv->key, field)) { @@ -2092,14 +2093,22 @@ gchar { g_string_erase (key_where, 0, 5); } + else + { + g_string_free (key_where, TRUE); + key_where = NULL; + } g_object_get (field, "field", &field_name, NULL); - new_val = gdaex_get_new_id (priv->gdaex, priv->table, field_name, key_where->str); + new_val = gdaex_get_new_id (priv->gdaex, priv->table, field_name, key_where == NULL ? NULL : key_where->str); gtk_form_widget_set_value_stringify (gtk_form_field_get_form_widget (field), g_strdup_printf ("%d", new_val)); - g_string_free (key_where, TRUE); + if (key_where != NULL) + { + g_string_free (key_where, TRUE); + } } value = gtk_form_field_get_value_sql (field); -- 2.49.0