From 7d68b2845128183b89bfe33106fba25e1243dc26 Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Thu, 30 Jul 2009 17:37:32 +0300 Subject: [PATCH] core: Copy the factory list before creating devices We iterate over the copy of the list rather than list itself because there is high chances of the original list being modified during the iteration, which is not allowed by libgee. --- src/rygel/rygel-main.vala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/rygel/rygel-main.vala b/src/rygel/rygel-main.vala index 8c95b3c..4f9ba0d 100644 --- a/src/rygel/rygel-main.vala +++ b/src/rygel/rygel-main.vala @@ -73,7 +73,15 @@ public class Rygel.Main : Object { private void on_plugin_loaded (PluginLoader plugin_loader, Plugin plugin) { + // We iterate over the copy of the list rather than list itself because + // there is high chances of the original list being modified during the + // iteration, which is not allowed by libgee. + var factories = new ArrayList (); foreach (var factory in this.factories) { + factories.add (factory); + } + + foreach (var factory in factories) { this.create_device (plugin, factory); } } @@ -109,6 +117,7 @@ public class Rygel.Main : Object { var factory = new RootDeviceFactory (context); this.factories.add (factory); + // See the comment in on_plugin_loaded method var plugins = new ArrayList (); foreach (var plugin in this.plugin_loader.list_plugins ()) { plugins.add (plugin); -- 2.7.4