[libgda] GdaDataModel row find corrections



commit 4fb15778fa37d458514812ff886ecedc990e71fc
Author: Vivien Malerba <malerba gnome-db org>
Date:   Wed Jul 28 17:36:32 2010 +0200

    GdaDataModel row find corrections

 libgda/gda-data-model.c |   15 ++++++++-------
 libgda/gda-data-proxy.c |   19 +++++++++----------
 2 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index c824f87..92317bb 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -943,18 +943,19 @@ gda_data_model_get_row_from_values (GdaDataModel *model, GSList *values, gint *c
                 const GValue *value;
                 gint index;
 
-                list = values;
-                index = 0;
-                while (list && allequal) {
+                for (list = values, index = 0;
+		     list;
+		     list = list->next, index++) {
                         if (cols_index)
                                 g_return_val_if_fail (cols_index [index] < n_cols, FALSE);
                         value = gda_data_model_get_value_at (model, cols_index [index], current_row, NULL);
 
-                        if (!value || !(list->data) || gda_value_compare ((GValue *) (list->data), (GValue *) value))
+                        if (!value || !(list->data) ||
+			    (G_VALUE_TYPE (value) != G_VALUE_TYPE ((GValue *) list->data)) ||
+			    gda_value_compare ((GValue *) (list->data), (GValue *) value)) {
                                 allequal = FALSE;
-
-                        list = g_slist_next (list);
-                        index++;
+				break;
+			}
                 }
 
                 if (allequal)
diff --git a/libgda/gda-data-proxy.c b/libgda/gda-data-proxy.c
index 5330011..35e5f01 100644
--- a/libgda/gda-data-proxy.c
+++ b/libgda/gda-data-proxy.c
@@ -3515,7 +3515,7 @@ gda_data_proxy_find_row_from_values (GdaDataModel *model, GSList *values, gint *
 	/* FIXME: use a virtual connection here with some SQL, it'll be much easier and will avoid
 	 * much code
 	 */
-	TO_IMPLEMENT;
+	/*TO_IMPLEMENT;*/
 
 	/* if there are still some rows waiting to be added in the idle loop, then force them to be added
 	 * first, otherwise we might not find what we are looking for!
@@ -3533,21 +3533,20 @@ gda_data_proxy_find_row_from_values (GdaDataModel *model, GSList *values, gint *
 		gint index;
 		const GValue *value;
 		
-		list = values;
-		index = 0;
-		while (list && allequal) {
+		for (list = values, index = 0;
+		     list;
+		     list = list->next, index++) {
 			if (cols_index)
 				g_return_val_if_fail (cols_index [index] < proxy->priv->model_nb_cols, FALSE);
 			value = gda_data_proxy_get_value_at ((GdaDataModel *) proxy, 
 							     cols_index ? cols_index [index] : 
 							     index, proxy_row, NULL);
-			if (!value)
-				return -1;
-			if (gda_value_compare ((GValue *) (list->data), (GValue *) value))
+			if ((!value) || !list->data ||
+			    (G_VALUE_TYPE (value) != G_VALUE_TYPE ((GValue *) list->data)) ||
+			    gda_value_compare ((GValue *) (list->data), (GValue *) value)) {
 				allequal = FALSE;
-
-			list = g_slist_next (list);
-			index++;
+				break;
+			}
 		}
 		if (allequal) {
 			found = TRUE;



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