core: When stopping sounds associated with movieclips, go by path instead of pointer - fixes #9795

This commit is contained in:
Nathan Adams 2024-07-06 22:55:57 +02:00
parent dda4cbfd62
commit 84df034f84
1 changed files with 10 additions and 1 deletions

View File

@ -504,7 +504,16 @@ impl<'gc> AudioManager<'gc> {
) {
self.sounds.retain(move |sound| {
if let Some(other) = sound.display_object {
if DisplayObject::ptr_eq(other, display_object) {
// [NA] This may or may not be correct, Flash is very inconsistent here
// If you make 50 movies with the same path and attach sounds to one of them,
// they all stop when you stop one of the movies.
// However, it also stops (some of?) them when they've changed their name too...
// Path can be expensive, so do the cheap checks first
if DisplayObject::ptr_eq(other, display_object)
|| (other.name() == display_object.name()
&& other.path() == display_object.path())
{
audio.stop_sound(sound.instance);
return false;
}