+ // if the sound is in a playing state, just mark it to be deleted and
+ // delete it after it plays. Otherwise, async sounds created on the stack
+ // may never get the chance to play.
+ bool isPlaying = false;
+ for ( wxVector<wxSoundData*>::reverse_iterator s = s_soundsPlaying.rbegin();
+ s != s_soundsPlaying.rend(); ++s )
+ {
+ if (*s == m_data)
+ {
+ isPlaying = true;
+ break;
+ }
+ }
+
+ if (isPlaying)
+ m_data->MarkForDeletion();
+ else
+ delete m_data;