Skip to content

Commit 52c04d7

Browse files
authored
Merge pull request #806 from sylt/fix-shutdown-crash
CollectionSystemManager: Fix possible crash in destructor
2 parents b5e1950 + dc96e7c commit 52c04d7

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
@@ -814,16 +814,19 @@ void CollectionSystemManager::removeCollectionsFromDisplayedSystems()
814814

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

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

0 commit comments

Comments
 (0)