diff --git a/Platform/Shared/VMWizardDrivesView.swift b/Platform/Shared/VMWizardDrivesView.swift index 28782c2e7..3daa362c4 100644 --- a/Platform/Shared/VMWizardDrivesView.swift +++ b/Platform/Shared/VMWizardDrivesView.swift @@ -25,11 +25,7 @@ struct VMWizardDrivesView: View { HStack { Text("Specify the size of the drive where data will be stored into.") Spacer() - NumberTextField("", number: $wizardState.storageSizeGib, onEditingChanged: { _ in - if wizardState.storageSizeGib < 1 { - wizardState.storageSizeGib = 1 - } - }) + NumberTextField("", number: $wizardState.storageSizeGib) .textFieldStyle(.roundedBorder) .frame(maxWidth: 50) Text("GB") diff --git a/Platform/Shared/VMWizardHardwareView.swift b/Platform/Shared/VMWizardHardwareView.swift index 8a5353d40..a0334c031 100644 --- a/Platform/Shared/VMWizardHardwareView.swift +++ b/Platform/Shared/VMWizardHardwareView.swift @@ -75,9 +75,7 @@ struct VMWizardHardwareView: View { } Section { RAMSlider(systemMemory: $wizardState.systemMemoryMib) { _ in - if wizardState.systemMemoryMib < minMemoryMib { - wizardState.systemMemoryMib = minMemoryMib - } else if wizardState.systemMemoryMib > maxMemoryMib { + if wizardState.systemMemoryMib > maxMemoryMib { wizardState.systemMemoryMib = maxMemoryMib } } diff --git a/Platform/Shared/VMWizardState.swift b/Platform/Shared/VMWizardState.swift index b4803cb00..eaf9aeab8 100644 --- a/Platform/Shared/VMWizardState.swift +++ b/Platform/Shared/VMWizardState.swift @@ -230,6 +230,10 @@ enum VMWizardOS: String, Identifiable { } nextPage = .hardware case .hardware: + guard systemMemoryMib > 0 else { + alertMessage = AlertMessage(NSLocalizedString("Invalid RAM size specified.", comment: "VMWizardState")) + return + } nextPage = .drives #if arch(arm64) if operatingSystem == .Windows && windowsBootVhdx != nil { @@ -246,6 +250,10 @@ enum VMWizardOS: String, Identifiable { } } case .drives: + guard storageSizeGib > 0 else { + alertMessage = AlertMessage(NSLocalizedString("Invalid drive size specified.", comment: "VMWizardState")) + return + } nextPage = .sharing if useAppleVirtualization { if #available(macOS 12, *) { diff --git a/Platform/macOS/VMConfigAppleSystemView.swift b/Platform/macOS/VMConfigAppleSystemView.swift index d05d8bf01..a7d5003aa 100644 --- a/Platform/macOS/VMConfigAppleSystemView.swift +++ b/Platform/macOS/VMConfigAppleSystemView.swift @@ -58,9 +58,7 @@ struct VMConfigAppleSystemView: View { .multilineTextAlignment(.trailing) } RAMSlider(systemMemory: $config.memorySize) { _ in - if config.memorySize < minMemory { - config.memorySize = minMemory - } else if config.memorySize > maxMemory { + if config.memorySize > maxMemory { config.memorySize = maxMemory } }