conduit r1602 - in trunk: . conduit/gtkui



Author: jstowers
Date: Wed Jul 30 04:45:24 2008
New Revision: 1602
URL: http://svn.gnome.org/viewvc/conduit?rev=1602&view=rev

Log:
2008-07-30  John Stowers  <john stowers gmail com>

	* conduit/gtkui/Database.py: Fix an off by one error in the database
	gtk.Liststore wrapper. This was exposed by a recent upgrade that changed
	how the gtk.Treeview iterated over its model.



Modified:
   trunk/ChangeLog
   trunk/conduit/gtkui/Database.py

Modified: trunk/conduit/gtkui/Database.py
==============================================================================
--- trunk/conduit/gtkui/Database.py	(original)
+++ trunk/conduit/gtkui/Database.py	Wed Jul 30 04:45:24 2008
@@ -130,22 +130,27 @@
         Parameters:
             oid -- the current oid.
         """
+        #first call is when oid=None
+        if not oid:
+            oid = -1
+            
         if GenericDBListStore.OID_CACHE:
             try:
                 index = self.oidcache.index(oid)
                 return self.oidcache[index+1]
             except (ValueError, IndexError):
-                sql = "SELECT oid FROM %s WHERE oid > %d LIMIT 1024" % (self.table, oid or -1)
+                sql = "SELECT oid FROM %s WHERE oid >= %d LIMIT 1024" % (self.table, oid)
                 oids = [oid for (oid,) in self.db.select(sql)]
                 self.oidcache.extend(oids)
                 self.oidcache = Utils.unique_list(self.oidcache)
-            if len(oids) > 0:
-                oid = oids[0] 
+            #if we can only get one result, we must be the last oid
+            if len(oids) > 1:
+                oid = oids[1] 
             else:
                 oid = None        
         else:
             try:
-                (oid,) = self.db.select_one("SELECT oid FROM %s WHERE oid > %d LIMIT 1" % (self.table, oid or -1))
+                (oid,) = self.db.select_one("SELECT oid FROM %s WHERE oid > %d LIMIT 1" % (self.table, oid))
             except TypeError:
                 oid = None
 



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