Add additional NULL checks just in case

This commit is contained in:
Crash Cringle
2025-03-22 12:02:04 -07:00
committed by teejusb
parent ce7cef6d90
commit 0270cda54d
3 changed files with 20 additions and 9 deletions
+4 -3
View File
@@ -97,10 +97,11 @@ void Profile::ClearSongs()
delete curr_song;
}
m_songs.clear();
LOG->Trace("Profile::ClearSongs()");
if (m_group != nullptr)
{
delete m_group;
RageUtil::SafeDelete( m_group);
}
}
@@ -1235,7 +1236,7 @@ void Profile::LoadSongsFromDir(RString const& dir, ProfileSlot prof_slot, bool i
float load_time= song_load_start_time.Ago();
LOG->Trace("Successfully loaded %zu songs in %.6f from profile.", m_songs.size(), load_time);
if (m_songs.size() <= 0) {
if (m_songs.empty()) {
delete m_group;
m_group = nullptr;
}
+1
View File
@@ -310,6 +310,7 @@ bool Song::LoadFromSongDir(RString sDir, bool load_autosave, ProfileSlot from_pr
}
else
{
LOG->Trace("Loading song from profile2.");
m_LoadedFromProfile= from_profile;
m_sGroupName= sDir.substr(1, sDir.find('/', 1) - 1);
use_cache= false;
+15 -6
View File
@@ -707,9 +707,12 @@ RageColor SongManager::GetSongGroupColor( const RString &sSongGroup ) const
Profile* prof= PROFILEMAN->GetProfile(pn);
if(prof != nullptr)
{
if(prof->m_group->GetGroupName() == sSongGroup)
if(prof->m_group != nullptr)
{
return profile_song_group_colors.GetValue(pn % num_profile_song_group_colors);
if(prof->m_group->GetGroupName() == sSongGroup)
{
return profile_song_group_colors.GetValue(pn % num_profile_song_group_colors);
}
}
}
}
@@ -881,9 +884,12 @@ const std::vector<Song*> &SongManager::GetSongs( const RString &sGroupName ) con
Profile* prof= PROFILEMAN->GetProfile(pn);
if(prof != nullptr)
{
if(prof->m_group->GetGroupName() == sGroupName)
if(prof->m_group != nullptr)
{
return prof->m_songs;
if(prof->m_group->GetGroupName() == sGroupName)
{
return prof->m_songs;
}
}
}
}
@@ -944,9 +950,12 @@ Group* SongManager::GetGroupFromName( const RString& sGroupName ) const
Profile* prof= PROFILEMAN->GetProfile(pn);
if(prof != nullptr)
{
if(prof->m_group->GetGroupName() == sGroupName)
if(prof->m_group != nullptr)
{
return prof->m_group;
if(prof->m_group->GetGroupName() == sGroupName)
{
return prof->m_group;
}
}
}
}