Prevent a crash when loading a group with no additions in SongManager::LoadSongDir
When reloading and only loading additions, ensure we do not delete/readd groups that were already loaded.
This commit is contained in:
@@ -436,10 +436,14 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
|
||||
RString group_base_name= Basename(sGroupDirName);
|
||||
Group* group = new Group(sDir, sGroupDirName);
|
||||
|
||||
// We need to keep track of previously loaded groups so we don't delete them if we're only loading additions
|
||||
bool groupAlreadyLoaded = false;
|
||||
// Add the group to the group mapping
|
||||
if (m_mapNameToGroup.find(sGroupDirName) == m_mapNameToGroup.end())
|
||||
{
|
||||
m_mapNameToGroup[sGroupDirName] = group;
|
||||
} else {
|
||||
groupAlreadyLoaded = true;
|
||||
}
|
||||
|
||||
for( unsigned j=0; j< arraySongDirs.size(); ++j ) // for each song dir
|
||||
@@ -485,6 +489,9 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
|
||||
|
||||
LOG->Trace("Loaded %i songs from \"%s\"", loaded, (sDir+sGroupDirName).c_str() );
|
||||
|
||||
// If we're only loading additions, already loaded groups should neither be added nor deleted
|
||||
if (!(groupAlreadyLoaded && onlyAdditions)) {
|
||||
|
||||
// Don't add the group name if we didn't load any songs in this group.
|
||||
if(!loaded) {
|
||||
// Remove the group from the group mapping
|
||||
@@ -502,6 +509,7 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
|
||||
|
||||
// Cache and load the group banner. (and background if it has one -aj)
|
||||
IMAGECACHE->CacheImage( "Banner", GetSongGroupBannerPath(sGroupDirName) );
|
||||
}
|
||||
|
||||
// Load the group sym links (if any)
|
||||
LoadGroupSymLinks(sDir, sGroupDirName);
|
||||
|
||||
Reference in New Issue
Block a user