MachOView icon indicating copy to clipboard operation
MachOView copied to clipboard

run MachOView is crash !

Open emptyglass123 opened this issue 5 years ago • 1 comments

截屏2020-07-16 下午3 35 58

crash reason : update UI in a Background thread

fix :

image

emptyglass123 avatar Jul 16 '20 08:07 emptyglass123

- (void)handleThreadStateChanged:(NSNotification *)notification
{
  if ([notification object] == dataController)
  {
    NSString * threadState = [[notification userInfo] objectForKey:MVStatusUserInfoKey];
    if ([threadState isEqualToString:MVStatusTaskStarted] == YES)
    {
      if (OSAtomicIncrement32(&threadCount) == 1)
      {
				dispatch_async(dispatch_get_main_queue(), ^{
					[progressIndicator setUsesThreadedAnimation:YES];
					[progressIndicator startAnimation:nil];
					[stopButton setHidden:NO];

				});
      }
    }
    else if ([threadState isEqualToString:MVStatusTaskTerminated] == YES)
    {
      if (OSAtomicDecrement32(&threadCount) == 0)
      {
				dispatch_async(dispatch_get_main_queue(), ^{
						[progressIndicator stopAnimation:nil];
						[statusText setStringValue:@""];
						[stopButton setHidden:YES];
				});
      }
    }
  }
}```

Wrap the crashed code with main queue dispatch

xiaoxiaowesley avatar Jan 11 '21 02:01 xiaoxiaowesley