Skip to content

Commit

Permalink
fixed issue #150 terminating GUI app when stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Hex committed Nov 19, 2024
1 parent 9390f28 commit 8dcce62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/gui-linux/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func run(ctx context.Context) error {
}

runtime.LockOSThread()
vm.StartGraphicApplication(960, 600)
vm.StartGraphicApplication(960, 600, vz.WithWindowTitle("Linux"), vz.WithController(true))
runtime.UnlockOSThread()

cleanup()
Expand Down
7 changes: 6 additions & 1 deletion virtualization_view.m
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
} else {
[self hideOverlay];
}
// Terminating GUI Application from Guest and Host.
// See: https://github.com/Code-Hex/vz/issues/150
if (newState == VZVirtualMachineStateStopped) {
[NSApp terminate:nil];
}
});
}
}
Expand Down Expand Up @@ -368,7 +373,7 @@ - (void)setToolBarItems:(NSArray<NSToolbarItemIdentifier> *)desiredItems
/* IMPORTANT: delegate methods are called from VM's queue */
- (void)guestDidStopVirtualMachine:(VZVirtualMachine *)virtualMachine
{
[NSApp performSelectorOnMainThread:@selector(terminate:) withObject:self waitUntilDone:NO];
// [NSApp performSelectorOnMainThread:@selector(terminate:) withObject:self waitUntilDone:NO];
}

- (void)virtualMachine:(VZVirtualMachine *)virtualMachine didStopWithError:(NSError *)error
Expand Down

0 comments on commit 8dcce62

Please sign in to comment.