iOS:fix when obj_retain DoricContext cause crash

This commit is contained in:
pengfeizhou
2021-02-09 15:09:52 +08:00
committed by osborn
parent a7e042174f
commit 3fa9124801
6 changed files with 23 additions and 19 deletions

View File

@@ -111,8 +111,7 @@ - (void)onConnectExceptionEvent {
- (void)onStartDebugEvent:(NSNotification *)notification {
NSString *contextId = notification.object;
ShowToast(contextId, DoricGravityBottom);
for (NSValue *value in [[DoricContextManager instance] aliveContexts]) {
DoricContext *context = value.nonretainedObjectValue;
for (DoricContext *context in [[DoricContextManager instance] aliveContexts]) {
BOOL result = [context.contextId compare:contextId] == NSOrderedSame;
if (result) {
_context = context;

View File

@@ -58,17 +58,18 @@ - (void)viewDidLoad {
[self.navigationController pushViewController:[QRScanViewController new] animated:NO];
}
}
- (void)onClose {
[[DoricDev instance] closeDevMode];
[self.navigationController popViewControllerAnimated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [DoricContextManager.instance aliveContexts].count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSValue *value = [DoricContextManager.instance aliveContexts][(NSUInteger) indexPath.row];
DoricContext *context = value.nonretainedObjectValue;
DoricContext *context = [DoricContextManager.instance aliveContexts][(NSUInteger) indexPath.row];
NSString *path = context.source;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
@@ -84,8 +85,7 @@ - (BOOL)isSimulator {
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSValue *value = [DoricContextManager.instance aliveContexts][(NSUInteger) indexPath.row];
DoricContext *context = value.nonretainedObjectValue;
DoricContext *context = [DoricContextManager.instance aliveContexts][(NSUInteger) indexPath.row];
[[NSNotificationCenter defaultCenter] postNotificationName:@"StartDebugEvent" object:context.contextId];
NSDictionary *jsonDic = @{
@"cmd": @"DEBUG",

View File

@@ -64,8 +64,7 @@ - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message {
} else if ([cmd compare:@"RELOAD"] == NSOrderedSame) {
NSString *source = [[dic valueForKey:@"source"] mutableCopy];
NSString *script = [dic valueForKey:@"script"];
for (NSValue *value in [[DoricContextManager instance] aliveContexts]) {
DoricContext *context = value.nonretainedObjectValue;
for (DoricContext *context in [[DoricContextManager instance] aliveContexts]) {
if ([source containsString:context.source] || [context.source isEqualToString:@"__dev__"]) {
[context reload:script];
}