Changeset

4728:7c81b04a4fed

modulemanager: Set module.environment before calling add_host, otherwise the module will get the parent's environment (thanks xnyhps and Maranda)
author Matthew Wild <mwild1@gmail.com>
date Fri, 27 Apr 2012 21:37:45 +0100
parents 4727:5ebf4096a2e1
children 4729:da3c1d980c04
files core/modulemanager.lua
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/core/modulemanager.lua	Fri Apr 27 20:01:21 2012 +0100
+++ b/core/modulemanager.lua	Fri Apr 27 21:37:45 2012 +0100
@@ -142,10 +142,10 @@
 			},{
 				__index = modulemap["*"][module_name].module;
 			});
+			local host_module = setmetatable({ module = host_module_api }, { __index = mod });
+			host_module_api.environment = host_module;
 			local ok, result, module_err = call_module_method(mod, "add_host", host_module_api);
 			if not ok or result == false then return nil, ok and module_err or result; end
-			local host_module = setmetatable({ module = host_module_api }, { __index = mod });
-			host_module.module.environment = host_module;
 			modulemap[host][module_name] = host_module;
 			return host_module;
 		end