Changeset

1851:0a4d4ba01db8

componentmanager: Preserve existing events table (if any) when registering a component
author Matthew Wild <mwild1@gmail.com>
date Wed, 30 Sep 2009 11:05:01 +0100
parents 1850:8f1871c1d456
children 1852:f9b58f37bc14
files core/componentmanager.lua
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/core/componentmanager.lua	Wed Sep 30 11:03:11 2009 +0100
+++ b/core/componentmanager.lua	Wed Sep 30 11:05:01 2009 +0100
@@ -83,9 +83,9 @@
 	end
 end
 
-function create_component(host, component)
+function create_component(host, component, events)
 	-- TODO check for host well-formedness
-	return { type = "component", host = host, connected = true, s2sout = {}, events = events_new() };
+	return { type = "component", host = host, connected = true, s2sout = {}, events = events or events_new() };
 end
 
 function register_component(host, component, session)
@@ -93,7 +93,7 @@
 		local old_events = hosts[host] and hosts[host].events;
 
 		components[host] = component;
-		hosts[host] = session or create_component(host, component);
+		hosts[host] = session or create_component(host, component, old_events);
 		
 		-- Add events object if not already one
 		if not hosts[host].events then