Shutdown in reverse registration order
authorEnrico Zini <enrico@enricozini.org>
Tue, 14 Jul 2009 16:04:38 +0000 (17:04 +0100)
committerEnrico Zini <enrico@enricozini.org>
Tue, 14 Jul 2009 16:04:38 +0000 (17:04 +0100)
vala/registry.vala

index 2c122bffe1ccfcf57db5f83721fb63ac997edbf2..ebb4f09e1277593b07b8cb840c5622322122fe56 100644 (file)
@@ -175,22 +175,26 @@ public abstract class Service : Resource {
 public class Registry : Resource
 {
        HashMap<string, Resource> members;
+       protected ArrayList<string> registration_order;
        public DBus.Connection sbus;
 
        construct {
                members = new HashMap<string, Resource>(str_hash, str_equal);
+               registration_order = new ArrayList<string>();
                sbus = DBus.Bus.get(DBus.BusType.SYSTEM);
        }
 
        public override void shutdown()
        {
-               foreach (Resource r in members.get_values())
-                       r.shutdown();
+               // Shutdown in reverse registration order
+               for (int i = registration_order.size - 1; i >= 0; --i) 
+                       members[registration_order[i]].shutdown();
        }
 
        public void register(string name, Resource obj)
        {
                members[name] = obj;
+               registration_order.add(name);
        }
 
        public Object? geto(string name)