diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/sfx/iterator.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index 8b6a17fac8..c1acda7f6c 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -1269,12 +1269,11 @@ static void song_iterator_remove_death_listener(SongIterator *it, TeeSongIterato } } -static void song_iterator_transfer_death_listeners(SongIterator *it, TeeSongIterator *old_client) { - song_iterator_remove_death_listener(it, old_client); +static void song_iterator_transfer_death_listeners(SongIterator *it, SongIterator *it_from) { for (int i = 0; i < SONGIT_MAX_LISTENERS; ++i) { - if (old_client->_deathListeners[i]) - song_iterator_add_death_listener(it, old_client->_deathListeners[i]); - old_client->_deathListeners[i] = 0; + if (it_from->_deathListeners[i]) + song_iterator_add_death_listener(it, it_from->_deathListeners[i]); + it_from->_deathListeners[i] = 0; } } @@ -1514,6 +1513,7 @@ SongIterator *TeeSongIterator::handleMessage(Message msg) { delete _children[TEE_LEFT].it; _children[TEE_LEFT].it = 0; old_it = _children[TEE_RIGHT].it; + song_iterator_remove_death_listener(old_it, this); song_iterator_transfer_death_listeners(old_it, this); delete this; return old_it; @@ -1521,6 +1521,7 @@ SongIterator *TeeSongIterator::handleMessage(Message msg) { delete _children[TEE_RIGHT].it; _children[TEE_RIGHT].it = 0; old_it = _children[TEE_LEFT].it; + song_iterator_remove_death_listener(old_it, this); song_iterator_transfer_death_listeners(old_it, this); delete this; return old_it; @@ -1593,9 +1594,11 @@ int songit_next(SongIterator **it, byte *buf, int *result, int mask) { ** cleanup iterator */ int channel_mask = (*it)->channel_mask; - if (mask & IT_READER_MAY_FREE) - delete *it; + SongIterator *old_it = *it; *it = new CleanupSongIterator(channel_mask); + song_iterator_transfer_death_listeners(*it, old_it); + if (mask & IT_READER_MAY_FREE) + delete old_it; retval = -9999; /* Continue */ } } while (!( /* Until one of the following holds */ |