Skip to content

Commit

Permalink
ui: fix drive move down not working on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Feb 26, 2021
1 parent b8155e9 commit 54153f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 0 additions & 3 deletions Configuration/UTMConfiguration+Drives.m
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ - (void)moveDriveIndex:(NSInteger)index to:(NSInteger)newIndex {
NSMutableDictionary *drive = self.rootDict[kUTMConfigDrivesKey][index];
[self propertyWillChange];
[self.rootDict[kUTMConfigDrivesKey] removeObjectAtIndex:index];
if (index < newIndex) {
newIndex--;
}
[self.rootDict[kUTMConfigDrivesKey] insertObject:drive atIndex:newIndex];
}

Expand Down
2 changes: 1 addition & 1 deletion Managers/UTMQemuSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ - (void)argsForCpu {
}

- (void)argsForDrives {
NSInteger bootindex = 1;
NSInteger bootindex = 0;
for (NSUInteger i = 0; i < self.configuration.countDrives; i++) {
NSString *path = [self.configuration driveImagePathForIndex:i];
UTMDiskImageType type = [self.configuration driveImageTypeForIndex:i];
Expand Down
8 changes: 7 additions & 1 deletion Platform/iOS/VMConfigDrivesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ struct VMConfigDrivesView: View {

private func moveDrives(source: IndexSet, destination: Int) {
for offset in source {
config.moveDrive(offset, to: destination)
let realDestination: Int
if offset < destination {
realDestination = destination - 1
} else {
realDestination = destination
}
config.moveDrive(offset, to: realDestination)
}
}
}
Expand Down

0 comments on commit 54153f7

Please sign in to comment.