Skip to content

Commit

Permalink
fixed calling deleteStateHandler after called dealloc of VZVirtualMac…
Browse files Browse the repository at this point in the history
…hine
  • Loading branch information
Code-Hex committed Apr 15, 2023
1 parent 7f648b6 commit 6384483
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions virtualization_11.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,9 @@ @implementation Observer
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;
{

@autoreleasepool {
if ([keyPath isEqualToString:@"state"]) {
int newState = (int)[change[NSKeyValueChangeNewKey] integerValue];
changeStateOnObserver(newState, context);
} else {
// bool canVal = (bool)[change[NSKeyValueChangeNewKey] boolValue];
// char *vmid = copyCString((NSString *)context);
// char *key = copyCString(keyPath);
// changeCanPropertyOnObserver(canVal, vmid, key);
// free(vmid);
// free(key);
}
if ([keyPath isEqualToString:@"state"]) {
int newState = (int)[change[NSKeyValueChangeNewKey] integerValue];
changeStateOnObserver(newState, context);
}
}
@end
Expand All @@ -46,9 +37,9 @@ - (instancetype)initWithConfiguration:(VZVirtualMachineConfiguration *)configura
- (void)dealloc
{
[self removeObserver:_observer forKeyPath:@"state"];
deleteStateHandler(_stateHandler);
[_observer release];
[super dealloc];
deleteStateHandler(_stateHandler);
}
@end

Expand Down

0 comments on commit 6384483

Please sign in to comment.