media-export: Properly cancel the file monitor
authorJens Georg <mail@jensge.org>
Wed, 13 Apr 2011 18:00:45 +0000 (21:00 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 13 Apr 2011 19:35:22 +0000 (22:35 +0300)
src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala

index 65b4469..9925025 100644 (file)
@@ -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,