Skip to content

Commit

Permalink
Merge pull request #163 from atmaxinger/fix-devpollcdrom
Browse files Browse the repository at this point in the history
Mac GUI: don't show /dev/poll/cdrom if it is configured as cdrom
  • Loading branch information
asvitkine committed Feb 25, 2018
2 parents 588a2ae + e791a1f commit 2e302d6
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm
Expand Up @@ -120,11 +120,14 @@ - (void) setupGUI
/* Fetch all CDROMs */
index = 0;
while ((dsk = PrefsFindString("cdrom", index++)) != NULL) {
DiskType *disk = [[[DiskType alloc] init] autorelease];
[disk setPath:[NSString stringWithUTF8String: dsk ]];
[disk setIsCDROM:YES];
NSString *path = [NSString stringWithUTF8String: dsk ];
if (![path hasPrefix:@"/dev/"]) {
DiskType *disk = [[[DiskType alloc] init] autorelease];
[disk setPath:[NSString stringWithUTF8String: dsk ]];
[disk setIsCDROM:YES];

[diskArray addObject:disk];
[diskArray addObject:disk];
}
}

[disks setDataSource: self];
Expand Down Expand Up @@ -403,10 +406,19 @@ - (void) saveChanges: (id) sender
// Remove all disks
while (PrefsFindString("disk"))
PrefsRemoveItem("disk");
// Remove all cdroms
while (PrefsFindString("cdrom"))
PrefsRemoveItem("cdrom");

// Remove all cdroms (but keep the ones in /dev/)
const char *path;
int index = 0;
while ((path = PrefsFindString("cdrom", index)) != NULL) {
NSString *p = [NSString stringWithUTF8String: path];
if (![p hasPrefix:@"/dev/"]) {
PrefsRemoveItem("cdrom", index);
} else {
// only increase the index if the current entry has not been deleted
// if it has been deleted, the next entry is on the current entrys index
index++;
}
}

// Write all disks
for (int i = 0; i < [diskArray count]; i++) {
Expand Down

0 comments on commit 2e302d6

Please sign in to comment.