Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Confirm & stop the VM when the user closes the window if it is neither idle nor stopped. #389

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions VirtualUI/Source/Session/VirtualMachineSessionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public struct VirtualMachineSessionView: View {
{ [weak controller] in
guard let controller else { return true }

guard controller.isStarting || controller.isRunning else { return true }
if controller.isIdle || controller.isStopped { return true }

let confirmed = await NSAlert.runConfirmationAlert(
title: "Stop Virtual Machine?",
Expand Down Expand Up @@ -272,12 +272,19 @@ struct VMCircularButtonStyle: ButtonStyle {
}

extension VMController {
var isIdle: Bool {
return state == .idle
}
var isStarting: Bool {
guard case .starting = state else { return false }
return true
}
var isRunning: Bool {
guard case .running = state else { return false }
return true
}
var isStarting: Bool {
guard case .starting = state else { return false }
var isStopped: Bool {
guard case .stopped = state else { return false }
return true
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reordered to match VMState.

}
Expand Down