From fca57e256993ea5c83978c92e5ed2d58e518327b Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Tue, 13 Aug 2013 11:43:31 -0400 Subject: [PATCH] editor: fix crash on revert from disk This still doesn't read in the timing data from disk, but hey, at least it doesn't crash now. --- src/Song.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Song.cpp b/src/Song.cpp index ceb30aae4e..989947003e 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -362,6 +362,9 @@ bool Song::LoadFromSongDir( RString sDir ) return true; // do load this song } +/* This function feels EXTREMELY hacky - copying things on top of pointers so + * they don't break elsewhere. Maybe it could be rewritten to politely ask the + * Song/Steps objects to reload themselves. -- djpohly */ bool Song::ReloadFromSongDir( RString sDir ) { RemoveAutoGenNotes(); @@ -373,10 +376,14 @@ bool Song::ReloadFromSongDir( RString sDir ) copy.RemoveAutoGenNotes(); *this = copy; - // First we assemble a map to let us easily find the new steps + /* 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 + * easily find the new steps. */ map mNewSteps; for( vector::const_iterator it = m_vpSteps.begin(); it != m_vpSteps.end(); ++it ) { + (*it)->m_pSong = this; + StepsID id; id.FromSteps( *it ); mNewSteps[id] = *it;