iOS:add protection for SIGSEGV

This commit is contained in:
pengfei.zhou
2020-04-20 11:03:48 +08:00
committed by osborn
parent 4ef508d3a7
commit de9b96c490
8 changed files with 59 additions and 15 deletions

View File

@@ -40,8 +40,13 @@ - (instancetype)initWithContext:(DoricContext *)context callbackId:(NSString *)c
}
- (void)resolve:(id)result {
[[self.context.driver invokeDoricMethod:DORIC_BRIDGE_RESOLVE, self.context.contextId, self.callbackId, result, nil]
__weak typeof(self) __self = self;
[[self.context.driver invokeDoricMethod:DORIC_BRIDGE_RESOLVE
argumentsArray:result
? @[self.context.contextId, self.callbackId, result]
: @[self.context.contextId, self.callbackId]]
setExceptionCallback:^(NSException *e) {
__strong typeof(__self) self = __self;
[self.context.driver.registry
onException:e
inContext:self.context];
@@ -49,8 +54,13 @@ - (void)resolve:(id)result {
}
- (void)reject:(id)result {
[[self.context.driver invokeDoricMethod:DORIC_BRIDGE_REJECT, self.context.contextId, self.callbackId, result, nil]
__weak typeof(self) __self = self;
[[self.context.driver invokeDoricMethod:DORIC_BRIDGE_REJECT
argumentsArray:result
? @[self.context.contextId, self.callbackId, result]
: @[self.context.contextId, self.callbackId]]
setExceptionCallback:^(NSException *e) {
__strong typeof(__self) self = __self;
[self.context.driver.registry
onException:e
inContext:self.context];