[rygel] media-export: Fix error reporting in cursor API



commit 475139be5182e9d4642c7fa1998b0b372e62ce7b
Author: Jens Georg <jensg openismus com>
Date:   Thu Mar 14 12:37:12 2013 +0100

    media-export: Fix error reporting in cursor API
    
    has_next() was supposed to cache the error and next() to throw it, but
    has_next() was returning "false" on errors so the next() to throw was never
    called, causing database errors to disappear.
    
    This patch just changes has_next () to throw on error.

 .../rygel-media-export-database-cursor.vala        |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-database-cursor.vala 
b/src/plugins/media-export/rygel-media-export-database-cursor.vala
index 836a7c8..55a538b 100644
--- a/src/plugins/media-export/rygel-media-export-database-cursor.vala
+++ b/src/plugins/media-export/rygel-media-export-database-cursor.vala
@@ -91,12 +91,14 @@ internal class Rygel.MediaExport.DatabaseCursor : SqliteWrapper {
      *
      * @return true if more rows left, false otherwise
      */
-    public bool has_next () {
+    public bool has_next () throws DatabaseError {
         if (this.dirty) {
             this.current_state = this.statement.step ();
             this.dirty = false;
         }
 
+        this.throw_if_code_is_error (this.current_state);
+
         return this.current_state == Sqlite.ROW || this.current_state == -1;
     }
 
@@ -134,7 +136,7 @@ internal class Rygel.MediaExport.DatabaseCursor : SqliteWrapper {
             this.cursor = cursor;
         }
 
-        public bool next () {
+        public bool next () throws DatabaseError {
             return this.cursor.has_next ();
         }
 


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