core: Prevent possible crash on Ctrl-C
authorJens Georg <mail@jensge.org>
Tue, 18 Jan 2011 19:33:07 +0000 (20:33 +0100)
committerJens Georg <mail@jensge.org>
Tue, 18 Jan 2011 19:51:01 +0000 (20:51 +0100)
src/rygel/rygel-main.vala

index 1753c2b..f729c5b 100644 (file)
@@ -187,9 +187,14 @@ public class Rygel.Main : Object {
             device.available = plugin.active &&
                                this.config.get_upnp_enabled ();
 
-            this.root_devices.add (device);
+            // Due to pure evilness of unix sinals this might actually happen
+            // if someone shuts down rygel while the call-back is running,
+            // leading to a crash on shutdown
+            if (this.root_devices != null) {
+                this.root_devices.add (device);
 
-            plugin.notify["active"].connect (this.on_plugin_active_notify);
+                plugin.notify["active"].connect (this.on_plugin_active_notify);
+            }
         } catch (GLib.Error error) {
             warning (_("Failed to create RootDevice for %s. Reason: %s"),
                      plugin.name,