Bug 532348: [python] NPE for method callbacks for EnvironmentModule
added checks that bootstrapper will use correct reference for
environment. previously the bootstrapper created a root environment
which was thrown away after the 'child' environment module got loaded.
Change-Id: I9cbf4c3fbbebd0df157b375291790d7b85df204f
diff --git a/plugins/org.eclipse.ease/src/org/eclipse/ease/modules/EnvironmentModule.java b/plugins/org.eclipse.ease/src/org/eclipse/ease/modules/EnvironmentModule.java
index 6b35962..60fd520 100644
--- a/plugins/org.eclipse.ease/src/org/eclipse/ease/modules/EnvironmentModule.java
+++ b/plugins/org.eclipse.ease/src/org/eclipse/ease/modules/EnvironmentModule.java
@@ -110,7 +110,9 @@
if (module == null)
throw new RuntimeException("Could not create module instance, see workspace log for more details");
- if (module instanceof IScriptModule)
+ if (module instanceof IEnvironment)
+ ((IScriptModule) module).initialize(getScriptEngine(), (IEnvironment) module);
+ else if (module instanceof IScriptModule)
((IScriptModule) module).initialize(getScriptEngine(), this);
fModuleNames.put(moduleName, module);
@@ -334,7 +336,11 @@
if (null == codeFactory)
return null;
- final String wrapperCode = codeFactory.createWrapper(this, instance, identifier, useCustomNamespace, getScriptEngine());
+ String wrapperCode;
+ if (instance instanceof IEnvironment)
+ wrapperCode = codeFactory.createWrapper((IEnvironment) instance, instance, identifier, useCustomNamespace, getScriptEngine());
+ else
+ wrapperCode = codeFactory.createWrapper(this, instance, identifier, useCustomNamespace, getScriptEngine());
if (useCustomNamespace)
return getScriptEngine().inject(new Script("Wrapper(" + instance.getClass().getSimpleName() + ")", wrapperCode));