Gracefully handle content lists that specify duplicate BSAs

Previously, if fed bad data, or a content list predated a BSA being moved to a non-user config file, or possibly in other situations (but not any of the obvious ones as those had other guards), the `selectedArchives` list could be longer than the number of archives available due to duplicate entries.

This ensures they're handled like entries specifying no-longer-present archives, and just skips the duplicates.
The same would happen elsewhere in similar situations, but those code paths aren't always taken.
pull/3236/head
AnyOldName3 2 months ago
parent cdf7bd74d5
commit 0537b53d21

@ -398,6 +398,9 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
continue; continue;
const auto name = match[0]->text(); const auto name = match[0]->text();
const auto oldrow = ui.archiveListWidget->row(match[0]); const auto oldrow = ui.archiveListWidget->row(match[0]);
// entries may be duplicated, e.g. if a content list predated a BSA being added to a non-user config file
if (oldrow < row)
continue;
ui.archiveListWidget->takeItem(oldrow); ui.archiveListWidget->takeItem(oldrow);
ui.archiveListWidget->insertItem(row, name); ui.archiveListWidget->insertItem(row, name);
ui.archiveListWidget->item(row)->setCheckState(Qt::Checked); ui.archiveListWidget->item(row)->setCheckState(Qt::Checked);

Loading…
Cancel
Save