Skip to content

Commit

Permalink
get rid of more delete song stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Dec 6, 2018
1 parent fb319da commit fc88c33
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 64 deletions.
30 changes: 0 additions & 30 deletions src/ScreenNetSelectMusic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ AutoScreenMessage(SM_RefreshWheelLocation);
AutoScreenMessage(SM_SongChanged);
AutoScreenMessage(SM_UsersUpdate);
AutoScreenMessage(SM_BackFromPlayerOptions);
AutoScreenMessage(SM_ConfirmDeleteSong);
AutoScreenMessage(ETTP_SelectChart);
AutoScreenMessage(ETTP_StartChart);
AutoScreenMessage(ETTP_Disconnect);
Expand Down Expand Up @@ -206,41 +205,12 @@ ScreenNetSelectMusic::HandleScreenMessage(const ScreenMessage SM)
SelectSongUsingNSMAN(this, true);
} else if (SM == ETTP_SelectChart) {
SelectSongUsingNSMAN(this, false);
} else if (SM == SM_ConfirmDeleteSong) {
if (ScreenPrompt::s_LastAnswer == ANSWER_YES) {
OnConfirmSongDeletion();
} else {
// need to resume the song preview that was automatically paused
m_MusicWheel.ChangeMusic(0);
}
}

// Must be at end, as so it is last resort for SMOnline packets.
// If it doesn't know what to do, then it'll just remove them.
ScreenSelectMusic::HandleScreenMessage(SM);
}

void
ScreenNetSelectMusic::OnConfirmSongDeletion()
{
Song* deletedSong = m_pSongAwaitingDeletionConfirmation;
if (!deletedSong) {
LOG->Warn("Attempted to delete a null song "
"(ScreenSelectMusic::OnConfirmSongDeletion)");
return;
}

RString deleteDir = deletedSong->GetSongDir();
// flush the deleted song from any caches
SONGMAN->UnlistSong(deletedSong);
// refresh the song list
m_MusicWheel.ReloadSongList(false, "");
LOG->Trace("Deleting song: '%s'\n", deleteDir.c_str());
// delete the song directory from disk
FILEMAN->DeleteRecursive(deleteDir);
m_pSongAwaitingDeletionConfirmation = NULL;
}

ScreenNetSelectMusic::~ScreenNetSelectMusic()
{
if (PREFSMAN->m_verbose_log > 1)
Expand Down
29 changes: 0 additions & 29 deletions src/SongManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,11 +905,6 @@ SongManager::FreeSongs()
m_pSongs.clear();
m_SongsByDir.clear();

// also free the songs that have been deleted from disk
for (unsigned i = 0; i < m_pDeletedSongs.size(); ++i)
SAFE_DELETE(m_pDeletedSongs[i]);
m_pDeletedSongs.clear();

m_mapSongGroupIndex.clear();
m_sSongGroupBannerPaths.clear();

Expand All @@ -921,30 +916,6 @@ SongManager::FreeSongs()
m_pShuffledSongs.clear();
}

void
SongManager::UnlistSong(Song* song)
{
// cannot immediately free song data, as it is needed temporarily
// for smooth audio transitions, etc. Instead, remove it from the
// m_pSongs list and store it in a special place where it can safely
// be deleted later.
m_pDeletedSongs.emplace_back(song);

// remove all occurences of the song in each of our song vectors
vector<Song*>* songVectors[3] = { &m_pSongs,
&m_pPopularSongs,
&m_pShuffledSongs };
for (int songVecIdx = 0; songVecIdx < 3; ++songVecIdx) {
vector<Song*>& v = *songVectors[songVecIdx];
for (size_t i = 0; i < v.size(); ++i) {
if (v[i] == song) {
v.erase(v.begin() + i);
--i;
}
}
}
}

bool
SongManager::IsGroupNeverCached(const RString& group) const
{
Expand Down
5 changes: 0 additions & 5 deletions src/SongManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class SongManager

void InitSongsFromDisk(LoadingWindow* ld);
void FreeSongs();
void UnlistSong(Song* song);
void Cleanup();

void Invalidate(const Song* pStaleSong);
Expand Down Expand Up @@ -190,10 +189,6 @@ class SongManager
unordered_map<string, Steps*> StepsByKey;

set<RString> m_GroupsToNeverCache;
/** @brief Hold pointers to all the songs that have been deleted from disk
* but must at least be kept temporarily alive for smooth audio transitions.
*/
vector<Song*> m_pDeletedSongs;
/** @brief The most popular songs ranked by number of plays. */
vector<Song*> m_pPopularSongs;
// vector<Song*> m_pRecentSongs; // songs recently played on the
Expand Down

0 comments on commit fc88c33

Please sign in to comment.