fix iOS crash when call Destory
This commit is contained in:
@@ -43,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property(nonatomic, strong) DoricRootNode *rootNode;
|
||||
@property(nonatomic, strong) NSMutableDictionary <NSString *, NSMutableDictionary <NSString *, DoricViewNode *> *> *headNodes;
|
||||
@property(nonatomic, copy) NSString *extra;
|
||||
@property(nonatomic, assign) BOOL destroyed;
|
||||
|
||||
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source extra:(NSString *)extra;
|
||||
|
||||
|
@@ -60,6 +60,7 @@ - (DoricViewNode *)targetViewNode:(NSString *)viewId {
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
_destroyed = YES;
|
||||
[[DoricContextManager instance] destroyContext:self];
|
||||
[self callEntity:DORIC_ENTITY_DESTROY withArgumentsArray:@[]];
|
||||
[self.driver destroyContext:self.contextId];
|
||||
|
@@ -34,6 +34,9 @@ @implementation DoricBridgeExtension
|
||||
|
||||
- (id)callNativeWithContextId:(NSString *)contextId module:(NSString *)module method:(NSString *)method callbackId:(NSString *)callbackId argument:(id)argument {
|
||||
__strong DoricContext *context = [[DoricContextManager instance] getContext:contextId];
|
||||
if (context.destroyed) {
|
||||
return nil;
|
||||
}
|
||||
Class pluginClass = [self.registry acquireNativePlugin:module];
|
||||
DoricNativePlugin *nativePlugin = context.pluginInstanceMap[module];
|
||||
if (nativePlugin == nil) {
|
||||
|
@@ -35,7 +35,9 @@ - (void)render:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
|
||||
__weak typeof(self) _self = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__strong typeof(_self) self = _self;
|
||||
|
||||
if (self.doricContext == nil) {
|
||||
return;
|
||||
}
|
||||
NSString *viewId = argument[@"id"];
|
||||
|
||||
if (self.doricContext.rootNode.viewId == nil && [@"Root" isEqualToString:argument[@"type"]]) {
|
||||
@@ -53,6 +55,9 @@ - (void)render:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
|
||||
|
||||
- (void)command:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.doricContext == nil) {
|
||||
return;
|
||||
}
|
||||
NSArray *viewIds = argument[@"viewIds"];
|
||||
id args = argument[@"args"];
|
||||
NSString *name = argument[@"name"];
|
||||
|
Reference in New Issue
Block a user