MachOView
MachOView copied to clipboard
run MachOView is crash !
crash reason : update UI in a Background thread
fix :
- (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