зеркало из https://github.com/mozilla/pjs.git
Enter context if need be; JavaAdapters may have callbacks on threads unassociated
with contexts.
This commit is contained in:
Родитель
b6784de5d6
Коммит
d608b0d326
|
@ -70,9 +70,16 @@ public class JavaAdapter extends ScriptableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Scriptable setAdapterProto(Scriptable obj, Object adapter) {
|
public static Scriptable setAdapterProto(Scriptable obj, Object adapter) {
|
||||||
Scriptable res = ScriptRuntime.toObject(ScriptableObject.getTopLevelScope(obj),adapter);
|
// We could be called from a thread not associated with a Context
|
||||||
|
Context cx = Context.enter();
|
||||||
|
try {
|
||||||
|
Scriptable topLevel = ScriptableObject.getTopLevelScope(obj);
|
||||||
|
Scriptable res = ScriptRuntime.toObject(topLevel, adapter);
|
||||||
res.setPrototype(obj);
|
res.setPrototype(obj);
|
||||||
return res;
|
return res;
|
||||||
|
} finally {
|
||||||
|
cx.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getAdapterSelf(Class adapterClass, Object adapter)
|
public static Object getAdapterSelf(Class adapterClass, Object adapter)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче