Add null checks for all ->GetGroup->getsomething calls
This commit is contained in:
+6
-2
@@ -802,8 +802,12 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
|
||||
unsigned j;
|
||||
for( j=i; j < arraySongs.size(); j++ )
|
||||
{
|
||||
if( SONGMAN->GetGroup(arraySongs[j])->GetGroupName() != sThisSection )
|
||||
if ( SONGMAN->GetGroup(arraySongs[j]) == nullptr ) {
|
||||
LOG->Warn( "Song %s has no group!", arraySongs[j]->GetSongDir().c_str() );
|
||||
continue;
|
||||
} else if ( SONGMAN->GetGroup(arraySongs[j])->GetGroupName() != sThisSection ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
iSectionCount = j-i;
|
||||
|
||||
@@ -847,7 +851,7 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
|
||||
sLastSection = sThisSection;
|
||||
}
|
||||
}
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Song, pSong, sLastSection, nullptr, SONGMAN->GetGroup(pSong), SONGMAN->GetSongColor(pSong), 0) );
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Song, pSong, sLastSection, nullptr, nullptr, SONGMAN->GetSongColor(pSong), 0) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+12
-2
@@ -477,7 +477,13 @@ bool Song::ReloadFromSongDir( RString sDir )
|
||||
return false;
|
||||
copy.RemoveAutoGenNotes();
|
||||
*this = copy;
|
||||
m_SongTiming.m_fBeat0GroupOffsetInSeconds = SONGMAN->GetGroup(this)->GetSyncOffset();
|
||||
|
||||
if (SONGMAN->GetGroup(this) != nullptr) {
|
||||
m_SongTiming.m_fBeat0GroupOffsetInSeconds = SONGMAN->GetGroup(this)->GetSyncOffset();
|
||||
} else {
|
||||
m_SongTiming.m_fBeat0GroupOffsetInSeconds = PREFSMAN->m_fMachineSyncBias;
|
||||
LOG->Warn("Song %s has no group, using machine sync bias.", m_sMainTitle.c_str());
|
||||
}
|
||||
|
||||
/* Go through the steps, first setting their Song pointer to this song
|
||||
* (instead of the copy used above), and constructing a map to let us
|
||||
@@ -493,7 +499,11 @@ bool Song::ReloadFromSongDir( RString sDir )
|
||||
// Reapply the Group Offset if the steps have their own timing data.
|
||||
if( mNewSteps[id]->m_Timing.empty() )
|
||||
continue;
|
||||
mNewSteps[id]->m_Timing.m_fBeat0GroupOffsetInSeconds = SONGMAN->GetGroup(this)->GetSyncOffset();
|
||||
if (SONGMAN->GetGroup(this) != nullptr)
|
||||
mNewSteps[id]->m_Timing.m_fBeat0GroupOffsetInSeconds = SONGMAN->GetGroup(this)->GetSyncOffset();
|
||||
else
|
||||
m_SongTiming.m_fBeat0GroupOffsetInSeconds = PREFSMAN->m_fMachineSyncBias;
|
||||
LOG->Warn("Song %s has no group, using machine sync bias.", m_sMainTitle.c_str());
|
||||
}
|
||||
|
||||
// Now we wipe out the new pointers, which were shallow copied and not deep copied...
|
||||
|
||||
+31
-6
@@ -600,9 +600,19 @@ void SongUtil::SortSongPointerArrayByGroup( std::vector<Song*> &vpSongsInOut )
|
||||
|
||||
int SongUtil::CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2)
|
||||
{
|
||||
RString s1 = "";
|
||||
RString s2 = "";
|
||||
|
||||
if( SONGMAN->GetGroup(pSong1) != nullptr )
|
||||
s1 = SONGMAN->GetGroup(pSong1)->GetSortTitle();
|
||||
else
|
||||
LOG->Warn("SongUtil::CompareSongPointersByGroup: %s has no group", pSong1->GetSongDir().c_str());
|
||||
|
||||
if( SONGMAN->GetGroup(pSong2) != nullptr )
|
||||
s2 = SONGMAN->GetGroup(pSong2)->GetSortTitle();
|
||||
else
|
||||
LOG->Warn("SongUtil::CompareSongPointersByGroup: %s has no group", pSong2->GetSongDir().c_str());
|
||||
|
||||
RString s1 = SONGMAN->GetGroup(pSong1)->GetSortTitle();
|
||||
RString s2 = SONGMAN->GetGroup(pSong2)->GetSortTitle();
|
||||
// Sort Titles are the same, fall back on group folder name
|
||||
if( s1 == s2 )
|
||||
{
|
||||
@@ -618,8 +628,19 @@ int SongUtil::CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2)
|
||||
|
||||
static int CompareSongPointersByGroupAndTitle( const Song *pSong1, const Song *pSong2 )
|
||||
{
|
||||
RString s1 = SONGMAN->GetGroup(pSong1)->GetSortTitle();
|
||||
RString s2 = SONGMAN->GetGroup(pSong2)->GetSortTitle();
|
||||
RString s1 = "";
|
||||
RString s2 = "";
|
||||
|
||||
if( SONGMAN->GetGroup(pSong1) != nullptr )
|
||||
s1 = SONGMAN->GetGroup(pSong1)->GetSortTitle();
|
||||
else
|
||||
LOG->Warn("SongUtil::CompareSongPointersByGroup: %s has no group", pSong1->GetSongDir().c_str());
|
||||
|
||||
if( SONGMAN->GetGroup(pSong2) != nullptr )
|
||||
s2 = SONGMAN->GetGroup(pSong2)->GetSortTitle();
|
||||
else
|
||||
LOG->Warn("SongUtil::CompareSongPointersByGroup: %s has no group", pSong2->GetSongDir().c_str());
|
||||
|
||||
// Sort Titles are the same, fall back on group folder name
|
||||
if( s1 == s2 )
|
||||
{
|
||||
@@ -669,8 +690,12 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
|
||||
case SORT_PREFERRED:
|
||||
return SONGMAN->SongToPreferredSortSectionName( pSong );
|
||||
case SORT_GROUP:
|
||||
// guaranteed not empty
|
||||
return SONGMAN->GetGroup(pSong)->GetGroupName();
|
||||
if ( SONGMAN->GetGroup(pSong) == nullptr ) {
|
||||
LOG->Warn("SongUtil::GetSectionNameFromSongAndSort: %s has no group", pSong->GetSongDir().c_str());
|
||||
return RString();
|
||||
} else {
|
||||
return SONGMAN->GetGroup(pSong)->GetGroupName();
|
||||
}
|
||||
case SORT_TITLE:
|
||||
case SORT_ARTIST:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user