[evolution-data-server/openismus-work-master: 133/137] EBookBackendSqliteDB: Fixed e_book_backend_sqlitedb_cursor_calculate().



commit 05d0a8a8f946631db4b677e014bf3d6f7909edd7
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Sat Oct 19 01:11:00 2013 +0200

    EBookBackendSqliteDB: Fixed e_book_backend_sqlitedb_cursor_calculate().
    
    Now total + 1 is reported for a position at the "END" of the list.

 .../libedata-book/e-book-backend-sqlitedb.c        |   24 +++++++++++++++++--
 1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb.c 
b/addressbook/libedata-book/e-book-backend-sqlitedb.c
index 6431568..a914f1e 100644
--- a/addressbook/libedata-book/e-book-backend-sqlitedb.c
+++ b/addressbook/libedata-book/e-book-backend-sqlitedb.c
@@ -6223,16 +6223,26 @@ e_book_backend_sqlitedb_cursor_calculate (EBookBackendSqliteDB *ebsdb,
                                          GError              **error)
 {
        gboolean success = TRUE;
+       gint local_total = 0;
 
        g_return_val_if_fail (E_IS_BOOK_BACKEND_SQLITEDB (ebsdb), FALSE);
        g_return_val_if_fail (cursor != NULL, FALSE);
 
        /* If we're in a clear cursor state, then the position is 0 */
        if (position && cursor->state.values[0] == NULL) {
-               *position = 0;
 
-               /* Mark the local pointer NULL, no need to calculate this anymore */
-               position = NULL;
+               if (cursor->state.position == EBSDB_CURSOR_ORIGIN_BEGIN) {
+                       /* Mark the local pointer NULL, no need to calculate this anymore */
+                       *position = 0;
+                       position = NULL;
+               } else if (cursor->state.position == EBSDB_CURSOR_ORIGIN_END) {
+
+                       /* Make sure that we look up the total so we can
+                        * set the position to 'total + 1'
+                        */
+                       if (!total)
+                               total = &local_total;
+               }
        }
 
        /* Early return if there is nothing to do */
@@ -6258,8 +6268,16 @@ e_book_backend_sqlitedb_cursor_calculate (EBookBackendSqliteDB *ebsdb,
                /* The GError is already set. */
                book_backend_sqlitedb_rollback_transaction (ebsdb, NULL);
 
+
        UNLOCK_MUTEX (&ebsdb->priv->lock);
 
+       /* In the case we're at the end, we just set the position
+        * to be the total + 1
+        */
+       if (success && position && total &&
+           cursor->state.position == EBSDB_CURSOR_ORIGIN_END)
+               *position = *total + 1;
+
        return success;
 }
 


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