]> saetta.ns0.it Git - libgtkform/commitdiff
Bugfix: not considered where eq NULL for gdaex_get_new_id in GtkForm::get_sql.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 20 Nov 2013 07:45:20 +0000 (08:45 +0100)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 20 Nov 2013 07:45:20 +0000 (08:45 +0100)
libgtkform/form.c

index e6cf1ed07f1f1d2c00ce07ef62c2eaa5bcd61c20..eaacdd1998d7e1bb0d96c7907a74082396dd1695 100644 (file)
@@ -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);