Fixed an issue where repopulating collections did not update the filter indices correctly.

This commit is contained in:
Leon Styhre 2021-02-04 23:56:39 +01:00
parent 222c75a65b
commit 2e5b1b5187

View file

@ -957,7 +957,7 @@ void CollectionSystemsManager::repopulateCollection(SystemData* sysData)
it != mAutoCollectionSystemsData.cend(); it++) { it != mAutoCollectionSystemsData.cend(); it++) {
if ((*it).second.system == sysData) { if ((*it).second.system == sysData) {
LOG(LogDebug) << "CollectionSystemsManager::repopulateCollection(): " LOG(LogDebug) << "CollectionSystemsManager::repopulateCollection(): "
"Repopulating auto collection '" << it->first << "'."; "Repopulating auto collection \"" << it->first << "\"";
CollectionSystemData* autoSystem = &mAutoCollectionSystemsData[it->first]; CollectionSystemData* autoSystem = &mAutoCollectionSystemsData[it->first];
std::vector<FileData*> systemEntries = std::vector<FileData*> systemEntries =
@ -970,13 +970,15 @@ void CollectionSystemsManager::repopulateCollection(SystemData* sysData)
if (systemEntries.empty()) if (systemEntries.empty())
return; return;
// Delete all children from the system and remove them from the index too. // Delete all children from the system.
for (FileData* entry : systemEntries) { for (FileData* entry : systemEntries) {
autoSystem->system->getIndex()->removeFromIndex(entry);
autoSystem->system->getRootFolder()->removeChild(entry); autoSystem->system->getRootFolder()->removeChild(entry);
delete entry; delete entry;
} }
// Reset the filters so that they get rebuilt correctly when populating the collection.
autoSystem->system->getIndex()->resetIndex();
autoSystem->isPopulated = false; autoSystem->isPopulated = false;
populateAutoCollection(autoSystem); populateAutoCollection(autoSystem);
@ -1097,8 +1099,8 @@ void CollectionSystemsManager::populateAutoCollection(CollectionSystemData* sysD
include = include && (*gameIt)->metadata.get("playcount") > "0"; include = include && (*gameIt)->metadata.get("playcount") > "0";
break; break;
case AUTO_FAVORITES: case AUTO_FAVORITES:
// We may still want to add files we don't // We may still want to add files we don't want in auto collections
// want in auto collections in "favorites" // to "favorites".
include = (*gameIt)->metadata.get("favorite") == "true"; include = (*gameIt)->metadata.get("favorite") == "true";
break; break;
default: default: