Skip to content

Commit

Permalink
settings(iOS): do not evaluate isSupported every view update
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Jan 2, 2023
1 parent 8445a62 commit 6d56dc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion Managers/UTMQemuVirtualMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public extension UTMQemuVirtualMachine {
#endif
let frameworksURL = contentsURL.appendingPathComponent("Frameworks", isDirectory: true)
let framework = frameworksURL.appendingPathComponent("qemu-" + arch + "-softmmu.framework/" + base + "qemu-" + arch + "-softmmu", isDirectory: false)
logger.error("\(framework.path)")
return FileManager.default.fileExists(atPath: framework.path)
}

Expand Down
4 changes: 3 additions & 1 deletion Platform/Shared/VMConfigSystemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ private struct HardwareOptions: View {
@Binding var warningMessage: WarningMessage?
@EnvironmentObject private var data: UTMData
@State private var isArchitectureFirstAppear: Bool = true
@State private var isArchitectureSupported: Bool = true
@State private var isTargetFirstAppear: Bool = true

var body: some View {
Expand All @@ -176,11 +177,12 @@ private struct HardwareOptions: View {
}
}
.onChange(of: config.architecture) { newValue in
isArchitectureSupported = UTMQemuVirtualMachine.isSupported(systemArchitecture: newValue)
if newValue != architecture {
architecture = newValue
}
}
if !UTMQemuVirtualMachine.isSupported(systemArchitecture: config.architecture) {
if !isArchitectureSupported {
Text("The selected architecture is unsupported in this version of UTM.")
.foregroundColor(.red)
}
Expand Down

0 comments on commit 6d56dc8

Please sign in to comment.