Re: [gnome-db] append row to data model.



2006/1/26, Bas Driessen <bas driessen xobas com>:
[...]
>
>  Thanks Vivian, that works OK. 1 record added to the table in the database
> and 1 row added to the datamodel. Perfect! Just a concern. This will now
> only work for hash implementations. I believe that the MySQL provider uses
> something else (have to look into again). Can we make this change more
> generic?

I did the changes and added a g_object_unref(row) because otherwise
there may be some problems. can you try the following:

static GdaRow *
gda_data_model_hash_append_values (GdaDataModelRow *model, const GList
*values, GError **error)
{
	gint len;
	GdaRow *row = NULL;

	g_return_val_if_fail (GDA_IS_DATA_MODEL_HASH (model), NULL);
	g_return_val_if_fail (values != NULL, NULL);

	len = g_list_length ((GList *) values);
	if (len != GDA_DATA_MODEL_HASH (model)->priv->number_of_columns) {
		g_set_error (error, 0, GDA_DATA_MODEL_VALUES_LIST_ERROR,
			     _("Wrong number of values in values list"));
		return NULL;
	}

	row = gda_row_new_from_list (GDA_DATA_MODEL (model), values);
	if (!GDA_DATA_MODEL_ROW_CLASS (G_OBJECT_GET_CLASS
(model))->append_row (model, row, error)) {
		g_object_unref (row);
		return NULL;
	}

	g_object_unref (row);
	return (GdaRow *) row;
}

Thanks,

Vivien



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]