From 84ac4d3fc90cbe0ab6a73f975fd53d1fb0a9aa71 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 1 May 2004 05:13:09 +0000 Subject: [PATCH] fix crash if a sound is played, copied, and then the parent is given over to RageSoundManager; don't think this ever actually happens --- stepmania/src/RageSoundManager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stepmania/src/RageSoundManager.cpp b/stepmania/src/RageSoundManager.cpp index a0a25f9c9f..40f949bb53 100644 --- a/stepmania/src/RageSoundManager.cpp +++ b/stepmania/src/RageSoundManager.cpp @@ -98,6 +98,16 @@ void RageSoundManager::Update(float delta) if( !(*it)->IsPlaying() ) ToDelete.insert( *it ); + /* Don't delete any sounds that are the parent of another sound. Always delete + * child sounds first. */ + for( it = owned_sounds.begin(); it != owned_sounds.end(); ++it ) + if( (*it)->GetOriginal() != (*it) ) // child + { + set::iterator parent = ToDelete.find( (*it)->GetOriginal() ); + if( parent != ToDelete.end() ) + ToDelete.erase( parent ); + } + for( it = ToDelete.begin(); it != ToDelete.end(); ++it ) owned_sounds.erase( *it ); g_SoundManMutex.Unlock(); /* finished with owned_sounds */