Skip to content

Commit 424c865

Browse files
authored
Merge pull request #125 from Code-Hex/fix/124
fixed calling deleteStateHandler after called dealloc of VZVirtualMachine
2 parents 7f648b6 + 6384483 commit 424c865

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

virtualization_11.m

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,9 @@ @implementation Observer
1010
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;
1111
{
1212

13-
@autoreleasepool {
14-
if ([keyPath isEqualToString:@"state"]) {
15-
int newState = (int)[change[NSKeyValueChangeNewKey] integerValue];
16-
changeStateOnObserver(newState, context);
17-
} else {
18-
// bool canVal = (bool)[change[NSKeyValueChangeNewKey] boolValue];
19-
// char *vmid = copyCString((NSString *)context);
20-
// char *key = copyCString(keyPath);
21-
// changeCanPropertyOnObserver(canVal, vmid, key);
22-
// free(vmid);
23-
// free(key);
24-
}
13+
if ([keyPath isEqualToString:@"state"]) {
14+
int newState = (int)[change[NSKeyValueChangeNewKey] integerValue];
15+
changeStateOnObserver(newState, context);
2516
}
2617
}
2718
@end
@@ -46,9 +37,9 @@ - (instancetype)initWithConfiguration:(VZVirtualMachineConfiguration *)configura
4637
- (void)dealloc
4738
{
4839
[self removeObserver:_observer forKeyPath:@"state"];
49-
deleteStateHandler(_stateHandler);
5040
[_observer release];
5141
[super dealloc];
42+
deleteStateHandler(_stateHandler);
5243
}
5344
@end
5445

0 commit comments

Comments
 (0)