From 0537b53d2101f1b82bd58b2b9cf77653dc316d36 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Tue, 22 Oct 2024 22:40:16 +0100 Subject: [PATCH] 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. --- apps/launcher/datafilespage.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 356a15de81..0357b44359 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -398,6 +398,9 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName) continue; const auto name = match[0]->text(); 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->insertItem(row, name); ui.archiveListWidget->item(row)->setCheckState(Qt::Checked);