From 61c74e1c25b30c2b5e83055115f3c5167189b590 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 25 Mar 2020 19:32:01 +0800 Subject: [PATCH] iOS:fix crash for command view --- .../Pod/Classes/Plugin/DoricShaderPlugin.m | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/doric-iOS/Pod/Classes/Plugin/DoricShaderPlugin.m b/doric-iOS/Pod/Classes/Plugin/DoricShaderPlugin.m index 702c6869..c7f17be8 100644 --- a/doric-iOS/Pod/Classes/Plugin/DoricShaderPlugin.m +++ b/doric-iOS/Pod/Classes/Plugin/DoricShaderPlugin.m @@ -95,34 +95,32 @@ - (void)findClass:(Class)clz target:(id)target method:(NSString *)name promise:( NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature]; invocation.selector = selector; invocation.target = target; - __weak __typeof__(self) _self = self; - dispatch_block_t block = ^() { - __strong __typeof__(_self) self = _self; - @try { - for (NSUInteger idx = 2; idx < methodSignature.numberOfArguments; idx++) { - if (idx - 2 > [array count]) { - break; - } - id param = [self createParamWithMethodName:array[idx - 2] promise:promise argument:argument]; - [invocation setArgument:¶m atIndex:idx]; + void *retValue; + @try { + NSMutableArray *tempArray = [NSMutableArray new]; + + for (NSUInteger idx = 2; idx < methodSignature.numberOfArguments; idx++) { + if (idx - 2 > [array count]) { + break; } - [invocation invoke]; - } @catch (NSException *exception) { - DoricLog(@"CallNative Error:%@", exception.reason); - [self.doricContext.driver.registry onException:exception inContext:self.doricContext]; + id param = [self createParamWithMethodName:array[idx - 2] promise:promise argument:argument]; + if (param) { + [tempArray addObject:param]; + } + [invocation setArgument:¶m atIndex:idx]; } - }; - dispatch_async(dispatch_get_main_queue(), ^{ - void *retValue; - block(); - const char *retType = methodSignature.methodReturnType; - if (!strcmp(retType, @encode(void))) { - } else { - [invocation getReturnValue:&retValue]; - id returnValue = (__bridge id) retValue; - [promise resolve:returnValue]; - } - }); + [invocation invoke]; + } @catch (NSException *exception) { + DoricLog(@"CallNative Error:%@", exception.reason); + [self.doricContext.driver.registry onException:exception inContext:self.doricContext]; + } + const char *retType = methodSignature.methodReturnType; + if (!strcmp(retType, @encode(void))) { + } else { + [invocation getReturnValue:&retValue]; + id returnValue = (__bridge id) retValue; + [promise resolve:returnValue]; + } } break; }