[rygel] core: Work-around a GObject constructor abuse



commit 680e47b7c7cde17056137f070b152f8b33ae3366
Author: Jens Georg <mail jensge org>
Date:   Tue Jul 12 10:28:07 2011 +0200

    core: Work-around a GObject constructor abuse
    
    GUPnPRootDevice defines a constructor that returns NULL on error,
    causing a crash since vala rightfully isn't expecting that.

 src/rygel/rygel-root-device.vala |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/src/rygel/rygel-root-device.vala b/src/rygel/rygel-root-device.vala
index fcce5f1..9984966 100644
--- a/src/rygel/rygel-root-device.vala
+++ b/src/rygel/rygel-root-device.vala
@@ -41,15 +41,18 @@ internal class Rygel.RootDevice: GUPnP.RootDevice {
                 description_path: description_path,
                 description_dir: description_dir);
 
-        this.services = new ArrayList<ServiceInfo> ();
+        // Yes, this can happen.
+        if (this != null) {
+            this.services = new ArrayList<ServiceInfo> ();
 
-        // Now create the sevice objects
-        foreach (ResourceInfo info in plugin.resource_infos) {
-            // FIXME: We only support plugable services for now
-            if (info.type.is_a (typeof (Service))) {
-                var service = this.get_service (info.upnp_type);
+            // Now create the sevice objects
+            foreach (ResourceInfo info in plugin.resource_infos) {
+                // FIXME: We only support plugable services for now
+                if (info.type.is_a (typeof (Service))) {
+                    var service = this.get_service (info.upnp_type);
 
-                this.services.add (service);
+                    this.services.add (service);
+                }
             }
         }
     }



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