[rygel] media-export: Properly cancel the file monitor



commit 4cfce952fe5d9a812b5fadcf2f71e9afdbc0aa64
Author: Jens Georg <mail jensge org>
Date:   Wed Apr 13 21:00:45 2011 +0300

    media-export: Properly cancel the file monitor

 .../rygel-media-export-recursive-file-monitor.vala |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala b/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala
index 65b4469..9925025 100644
--- a/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala
+++ b/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala
@@ -30,6 +30,9 @@ public class Rygel.MediaExport.RecursiveFileMonitor : Object {
         this.cancellable = cancellable;
         this.monitors = new HashMap<File, FileMonitor> (GLib.file_hash,
                                                         GLib.file_equal);
+        if (cancellable != null) {
+            cancellable.cancelled.connect (this.cancel);
+        }
     }
 
     public void on_monitor_changed (File             file,
@@ -79,13 +82,11 @@ public class Rygel.MediaExport.RecursiveFileMonitor : Object {
     }
 
     public void cancel () {
-        if (this.cancellable != null) {
-            this.cancellable.cancel ();
-        } else {
-            foreach (var monitor in this.monitors.values) {
-                monitor.cancel ();
-            }
+        foreach (var monitor in this.monitors.values) {
+            monitor.cancel ();
         }
+
+        this.monitors.clear ();
     }
 
     public signal void changed (File             file,



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