[gnome-db] Patch: backport of gda_data_model_foreach from HEAD



Here's a patch for the 1_0 branch that updates the changes in
gda_data_model_foreach. The main differences in 1_0 are that it does a
copy of the values in the row and ignores the return value from the
callback function.

With the new code from HEAD, it doesn't copy the values and if the
callback returns FALSE, it finishes.

Ok to commit?

May be we should also set the row parameter for the callback as const.

-- 
Gonzalo Paniagua Javier <gonzalo gnome-db org>
http://www.gnome-db.org/~gonzalo/



Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/ChangeLog,v
retrieving revision 1.560.2.31
diff -u -r1.560.2.31 ChangeLog
--- ChangeLog	30 Nov 2003 11:41:52 -0000	1.560.2.31
+++ ChangeLog	30 Nov 2003 16:16:41 -0000
@@ -1,3 +1,8 @@
+2003-11-30  Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+	* libgda/gda-data-model.c:
+	(gda_data_model_foreach): backported from HEAD.
+
 2003-11-30  Laurent Sansonetti <lrz gnome org>
 
 	* libgda/gda-parameter.c (gda_parameter_list_clear):
Index: libgda/gda-data-model.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-data-model.c,v
retrieving revision 1.36.2.4
diff -u -r1.36.2.4 gda-data-model.c
--- libgda/gda-data-model.c	29 Nov 2003 14:57:51 -0000	1.36.2.4
+++ libgda/gda-data-model.c	30 Nov 2003 16:16:42 -0000
@@ -657,32 +657,22 @@
 			GdaDataModelForeachFunc func,
 			gpointer user_data)
 {
-	gint cols;
 	gint rows;
-	gint c, r;
-	GdaRow *row;
+	gint r;
+	const GdaRow *row;
+	gboolean more;
 
 	g_return_if_fail (GDA_IS_DATA_MODEL (model));
 	g_return_if_fail (func != NULL);
 
 	rows = gda_data_model_get_n_rows (model);
-	cols = gda_data_model_get_n_columns (model);
-
-	for (r = 0; r < rows; r++) {
-		row = gda_row_new (model, cols);
-		for (c = 0; c < cols; c++) {
-			GdaValue *value;
-			value = gda_value_copy (gda_data_model_get_value_at (model, c, r));
-			memcpy (gda_row_get_value (row, c), value, sizeof (GdaValue));
-		}
-
+	more = TRUE;
+	for (r = 0; more && r < rows ; r++) {
+		row = gda_data_model_get_row (model, r);
 		/* call the callback function */
-		func (model, row, user_data);
-
-		gda_row_free (row);
+		more = func (model, (GdaRow *) row, user_data);
 	}
 }
-
 /**
  * gda_data_model_is_editing
  * @model: a #GdaDataModel object.


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