Add null checks for all ->GetGroup->getsomething calls

This commit is contained in:
Crash Cringle
2025-03-09 10:05:01 -07:00
committed by teejusb
parent 031cb7c8a2
commit c6ad4685a7
3 changed files with 49 additions and 10 deletions
+12 -2
View File
@@ -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...