Skip to content

Commit f5c2cfd

Browse files
committed
settings(apple): fix settings cancel running on wrong actor
1 parent 3a79d06 commit f5c2cfd

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Managers/UTMAppleVirtualMachine.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ import Virtualization
6767

6868
private var activeResourceUrls: [URL] = []
6969

70-
override func reloadConfiguration() throws {
70+
@MainActor override func reloadConfiguration() throws {
7171
let newConfig = try UTMAppleConfiguration.load(from: path) as! UTMAppleConfiguration
7272
let oldConfig = appleConfig
7373
config = UTMConfigurationWrapper(wrapping: newConfig)
74-
Task { @MainActor in
75-
updateConfigFromRegistry()
76-
if #available(macOS 12, *) {
77-
newConfig.system.boot.macRecoveryIpswURL = oldConfig.system.boot.macRecoveryIpswURL
78-
}
74+
updateConfigFromRegistry()
75+
if #available(macOS 12, *) {
76+
newConfig.system.boot.macRecoveryIpswURL = oldConfig.system.boot.macRecoveryIpswURL
7977
}
8078
}
8179

Platform/macOS/VMSettingsView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ struct VMSettingsView<Config: UTMConfiguration>: View {
6464

6565
func cancel() {
6666
presentationMode.wrappedValue.dismiss()
67-
data.busyWork {
68-
try data.discardChanges(for: self.vm)
67+
data.busyWorkAsync {
68+
try await data.discardChanges(for: self.vm)
6969
}
7070
}
7171
}

0 commit comments

Comments
 (0)