[libgda] data-select: fixed create_iter() to transfer full



commit b5d1508c320bf75be1b6cdb7d7cb0ad218d9b3bc
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Fri Feb 15 09:56:24 2019 -0600

    data-select: fixed create_iter() to transfer full

 libgda/gda-data-select.c         | 21 +++++++--------------
 tests/data-models/check_pmodel.c |  2 +-
 2 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/libgda/gda-data-select.c b/libgda/gda-data-select.c
index f60a2d394..fc542ea32 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -2158,15 +2158,13 @@ gda_data_select_create_iter (GdaDataModel *model)
                return GDA_DATA_MODEL_ITER (g_object_new (GDA_TYPE_DATA_SELECT_ITER,
                                                          "data-model", model, NULL));
        }
-       else {
-               /* Create the iter if necessary, or just return the existing iter: */
-               if (priv->iter == NULL) {
-                       priv->iter = GDA_DATA_MODEL_ITER (g_object_new (GDA_TYPE_DATA_SELECT_ITER,
-                                                                               "data-model", model, NULL));
-                       priv->sh->iter_row = -1;
-               }
-               return priv->iter;
+       /* Create the iter if necessary, or just return the existing iter: */
+       if (priv->iter == NULL) {
+               priv->iter = GDA_DATA_MODEL_ITER (g_object_new (GDA_TYPE_DATA_SELECT_ITER,
+                                                                       "data-model", model, NULL));
+               priv->sh->iter_row = -1;
        }
+       return g_object_ref (priv->iter);
 }
 
 static void update_iter (GdaDataSelect *imodel, GdaRow *prow);
@@ -2200,12 +2198,6 @@ gda_data_select_iter_next (GdaDataModel *model, GdaDataModelIter *iter)
        else
                target_iter_row = priv->sh->iter_row + 1;
 
-       if ((priv->sh->iter_row) >= gda_data_model_get_n_rows (model)) {
-               priv->sh->iter_row = G_MAXINT;
-               gda_data_model_iter_invalidate_contents (iter);
-               return FALSE;
-       }
-
        int_row = external_to_internal_row (GDA_DATA_SELECT (model), target_iter_row, &error);
        if (int_row < 0) {
                g_warning (_("Can't calculate internal row number: %s"),
@@ -2278,6 +2270,7 @@ gda_data_select_iter_prev (GdaDataModel *model, GdaDataModelIter *iter)
        prow = gda_data_select_get_stored_row (GDA_DATA_SELECT (model), int_row);
        if (!prow) {
                if (! CLASS (model)->fetch_prev) {
+                       g_warning (_("Internal error: No fetch_prev() method implementation for data model"));
                        gda_data_model_iter_invalidate_contents (iter);
                        return FALSE;
                }
diff --git a/tests/data-models/check_pmodel.c b/tests/data-models/check_pmodel.c
index f23a2250b..49a9d9c6a 100644
--- a/tests/data-models/check_pmodel.c
+++ b/tests/data-models/check_pmodel.c
@@ -1187,7 +1187,7 @@ test11 (GdaConnection *cnc)
        g_assert (iter != NULL);
        g_assert (GDA_IS_DATA_MODEL_ITER (iter));
        for (; gda_data_model_iter_move_next (iter);) {
-               //g_print ("Iter is now at row %d\n", gda_data_model_iter_get_row (iter));
+               g_print ("Iter is now at row %d\n", gda_data_model_iter_get_row (iter));
                gint i;
                for (i = 0; i < ncols; i++) {
                        const GValue *cvalue, *refcvalue;


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