display(iOS): make QEMU errors non-fatal

This commit is contained in:
osy 2024-02-21 10:53:25 -08:00
parent 8654fb3abc
commit 8c88fd9aa7
4 changed files with 3 additions and 13 deletions

View File

@ -1240,7 +1240,7 @@ class UTMRemoteData: UTMData {
func remoteVirtualMachineDidError(id: UUID, message: String) async {
if let session = VMSessionState.allActiveSessions.values.first(where: { $0.vm.id == id }) {
session.fatalError = message
session.nonfatalError = message
}
}

View File

@ -45,8 +45,6 @@ import SwiftUI
@Published var vmState: UTMVirtualMachineState = .stopped
@Published var fatalError: String?
@Published var nonfatalError: String?
@Published var primaryInput: CSInput?
@ -159,7 +157,7 @@ extension VMSessionState: UTMVirtualMachineDelegate {
nonisolated func virtualMachine(_ vm: any UTMVirtualMachine, didErrorWithMessage message: String) {
Task { @MainActor in
fatalError = message
nonfatalError = message
}
}

View File

@ -163,11 +163,6 @@ struct VMWindowView: View {
state.alert = .nonfatalError(message)
}
}
.onChange(of: session.fatalError) { newValue in
if session.activeWindow == state.id, let message = newValue {
state.alert = .fatalError(message)
}
}
.onChange(of: session.vmState) { [oldValue = session.vmState] newValue in
vmStateUpdated(from: oldValue, to: newValue)
}
@ -225,7 +220,7 @@ struct VMWindowView: View {
state.isRunning = false
}
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) {
if session.vmState == .stopped && session.fatalError == nil {
if session.vmState == .stopped {
session.stop()
}
}

View File

@ -24,8 +24,6 @@ import IOKit.pwr_mgt
@Published var vmState: UTMVirtualMachineState = .stopped
@Published var fatalError: String?
private var hasStarted: Bool = false
private var preventIdleSleepAssertion: IOPMAssertionID?
@ -61,7 +59,6 @@ import IOKit.pwr_mgt
nonisolated func virtualMachine(_ vm: any UTMVirtualMachine, didErrorWithMessage message: String) {
Task { @MainActor in
fatalError = message
NotificationCenter.default.post(name: .vmSessionError, object: nil, userInfo: ["Session": self, "Message": message])
if !hasStarted {
// if we got an error and haven't started, then cleanup