summaryrefslogtreecommitdiff
path: root/src/modlistviewactions.cpp
diff options
context:
space:
mode:
authorJeremy Rimpo <jeremy.rimpo@servermonkey.com>2022-10-20 22:54:29 -0500
committerJeremy Rimpo <jeremy.rimpo@servermonkey.com>2023-09-21 17:29:40 -0500
commitfba3d52f5645bf2b0ec4a61f9b7fed9c4d481637 (patch)
tree88e3dc83b3c629e205200c6e426024e533d2c57f /src/modlistviewactions.cpp
parent05edcc8ab4c47e2ec82a10e40ce0033371bf6fee (diff)
Preserve old category if Nexus category can't be mapped
Diffstat (limited to 'src/modlistviewactions.cpp')
-rw-r--r--src/modlistviewactions.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp
index b9d0f419..5fc2aea9 100644
--- a/src/modlistviewactions.cpp
+++ b/src/modlistviewactions.cpp
@@ -264,15 +264,17 @@ void ModListViewActions::assignCategories() const
{
for (auto mod : m_core.modList()->allMods()) {
ModInfo::Ptr modInfo = ModInfo::getByName(mod);
- for (auto category : modInfo->categories()) {
- modInfo->removeCategory(category);
- }
QString file = modInfo->installationFile();
auto download = m_core.downloadManager()->getDownloadIndex(file);
if (download >= 0) {
int nexusCategory = m_core.downloadManager()->getCategoryID(download);
- int category = CategoryFactory::instance()->resolveNexusID(nexusCategory);
- modInfo->setCategory(CategoryFactory::instance()->getCategoryID(category), true);
+ int newCategory = CategoryFactory::instance()->resolveNexusID(nexusCategory);
+ if (newCategory != 0) {
+ for (auto category : modInfo->categories()) {
+ modInfo->removeCategory(category);
+ }
+ }
+ modInfo->setCategory(CategoryFactory::instance()->getCategoryID(newCategory), true);
}
}
}
@@ -1109,7 +1111,8 @@ void ModListViewActions::remapCategory(const QModelIndexList& indices) const
if (downloadIndex >= 0) {
auto downloadInfo = m_core.downloadManager()->getFileInfo(downloadIndex);
unsigned int categoryIndex = CategoryFactory::instance()->resolveNexusID(downloadInfo->categoryID);
- modInfo->setPrimaryCategory(CategoryFactory::instance()->getCategoryID(categoryIndex));
+ if (categoryIndex != 0)
+ modInfo->setPrimaryCategory(CategoryFactory::instance()->getCategoryID(categoryIndex));
}
}
}