Skip to content

Commit

Permalink
Bug fix: Confirm & stop the VM when the user closes the window if it …
Browse files Browse the repository at this point in the history
…is neither idle nor stopped.
  • Loading branch information
sundresh authored and insidegui committed Aug 21, 2024
1 parent 4809ae8 commit 2263371
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions VirtualUI/Source/Session/VirtualMachineSessionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,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 @@ -270,12 +270,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
}
}
Expand Down

0 comments on commit 2263371

Please sign in to comment.