flag to create jscontext
This commit is contained in:
parent
f02fb05af4
commit
cfd618db32
|
@ -19,7 +19,7 @@
|
|||
@import Foundation;
|
||||
@import JavaScriptCore;
|
||||
|
||||
extern JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor);
|
||||
extern JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor, bool create);
|
||||
|
||||
@interface RealmReact : NSObject
|
||||
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
- (JSGlobalContextRef)ctx;
|
||||
@end
|
||||
|
||||
JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor) {
|
||||
JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor, bool create) {
|
||||
Ivar contextIvar = class_getInstanceVariable([executor class], "_context");
|
||||
if (!contextIvar) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
id rctJSContext = contextIvar ? object_getIvar(executor, contextIvar) : nil;
|
||||
if (!rctJSContext) {
|
||||
if (!rctJSContext && create) {
|
||||
Class RCTJavaScriptContext = NSClassFromString(@"RCTJavaScriptContext");
|
||||
if (RCTJavaScriptContext) {
|
||||
JSGlobalContextRef ctx = JSGlobalContextCreate(NULL);
|
||||
|
@ -119,7 +119,7 @@ JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor) {
|
|||
}
|
||||
|
||||
[executor executeBlockOnJavaScriptQueue:^{
|
||||
JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(executor);
|
||||
JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(executor, true);
|
||||
[RealmJS initializeContext:ctx];
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ static id<RCTJavaScriptExecutor> s_currentJavaScriptExecutor;
|
|||
s_currentJavaScriptExecutor = [bridge valueForKey:@"javaScriptExecutor"];
|
||||
|
||||
// FIXME: Remove this nonsense once the crashes go away when a test fails!
|
||||
JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(s_currentJavaScriptExecutor);
|
||||
JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(s_currentJavaScriptExecutor, false);
|
||||
if (ctx) {
|
||||
JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(ctx, false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue