[rygel] media-db: Make Database.exec cancellable



commit 205683fa9045de4da79e955b3a730c3ce4e0937e
Author: Jens Georg <mail jensge org>
Date:   Sun Jan 31 15:03:27 2010 +0100

    media-db: Make Database.exec cancellable

 src/rygel/rygel-database.vala |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/rygel/rygel-database.vala b/src/rygel/rygel-database.vala
index b1b9a66..818d3c6 100644
--- a/src/rygel/rygel-database.vala
+++ b/src/rygel/rygel-database.vala
@@ -52,17 +52,22 @@ internal class Rygel.Database : Object {
 
     public int exec (string        sql,
                      GLib.Value[]? values   = null,
-                     RowCallback?  callback = null) throws DatabaseError {
+                     RowCallback?  callback = null,
+                     Cancellable?  cancellable = null) throws DatabaseError {
         #if RYGEL_DEBUG_SQL
         var t = new Timer ();
         #endif
         int rc;
 
-        if (values == null && callback == null) {
+        if (values == null && callback == null && cancellable == null) {
             rc = this.db.exec (sql);
         } else {
             var statement = prepare_statement (sql, values);
             while ((rc = statement.step ()) == Sqlite.ROW) {
+                if (cancellable != null && cancellable.is_cancelled ()) {
+                    break;
+                }
+
                 if (callback != null) {
                     if (!callback (statement)) {
                         rc = Sqlite.DONE;



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