Make the module resident rather than keeping a ref to it.
authorZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Fri, 28 Nov 2008 12:59:41 +0000 (12:59 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Fri, 28 Nov 2008 12:59:41 +0000 (12:59 +0000)
Rygel was crashing on exit because of modules being unloaded while there
were still objects of classes provided by the module. I thought I had
solved the issue by keeping a ref to each module in the PluginLoader but
the problem with that approach is that it is not guaranteed the
PluginLoader will not be freed before all the objects of classes it
provides.

svn path=/trunk/; revision=318

src/rygel/rygel-plugin-loader.vala

index daae865..a942c5d 100644 (file)
@@ -32,19 +32,11 @@ using GUPnP;
  * calls it and expects a Plugin instance in return.
  */
 public class Rygel.PluginLoader : Object {
-    /* We need to keep the modules somewhere */
-    private List<Module> modules;
-
     private delegate Plugin LoadPluginFunc ();
 
     // Signals
     public signal void plugin_available (Plugin plugin);
 
-    /* Pubic methods */
-    public PluginLoader () {
-        this.modules = new List<Module> ();
-    }
-
     // Plugin loading functions
     public void load_plugins () {
         assert (Module.supported());
@@ -117,8 +109,10 @@ public class Rygel.PluginLoader : Object {
 
         Plugin plugin = load_plugin ();
         if (plugin != null) {
+            // We don't want our modules to ever unload
+            module.make_resident ();
+
             this.plugin_available (plugin);
-            this.modules.append (#module);
         }
     }