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))
{
{
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);