Skip to content

Commit dc96e7c

Browse files
committed
CollectionSystemManager: Fix possible crash in destructor
This could happen if no mCustomCollectionsBundle was initialized.
1 parent 86a0823 commit dc96e7c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

es-app/src/CollectionSystemManager.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -813,16 +813,19 @@ void CollectionSystemManager::removeCollectionsFromDisplayedSystems()
813813

814814
// remove all custom collections in bundle
815815
// this should not delete the objects from memory!
816-
FileData* customRoot = mCustomCollectionsBundle->getRootFolder();
817-
std::vector<FileData*> mChildren = customRoot->getChildren();
818-
for(auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
816+
if (mCustomCollectionsBundle)
819817
{
820-
customRoot->removeChild(*it);
818+
FileData* customRoot = mCustomCollectionsBundle->getRootFolder();
819+
std::vector<FileData*> mChildren = customRoot->getChildren();
820+
for(auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
821+
{
822+
customRoot->removeChild(*it);
823+
}
824+
// clear index
825+
mCustomCollectionsBundle->getIndex()->resetIndex();
826+
// remove view so it's re-created as needed
827+
ViewController::get()->removeGameListView(mCustomCollectionsBundle);
821828
}
822-
// clear index
823-
mCustomCollectionsBundle->getIndex()->resetIndex();
824-
// remove view so it's re-created as needed
825-
ViewController::get()->removeGameListView(mCustomCollectionsBundle);
826829
}
827830

828831
void CollectionSystemManager::addEnabledCollectionsToDisplayedSystems(std::map<std::string, CollectionSystemData>* colSystemData)

0 commit comments

Comments
 (0)