Skip to content

Commit

Permalink
wizard: allow memory and storage size to be cleared
Browse files Browse the repository at this point in the history
Resolves #5885
  • Loading branch information
osy committed Mar 30, 2024
1 parent 4d88c35 commit e89346d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 1 addition & 5 deletions Platform/Shared/VMWizardDrivesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 1 addition & 3 deletions Platform/Shared/VMWizardHardwareView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
8 changes: 8 additions & 0 deletions Platform/Shared/VMWizardState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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, *) {
Expand Down
4 changes: 1 addition & 3 deletions Platform/macOS/VMConfigAppleSystemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit e89346d

Please sign in to comment.