diff options
author | Willem Jan Palenstijn | 2009-07-05 01:16:53 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2009-07-05 01:16:53 +0000 |
commit | eba5780fc062d26ba2d70d3bc438265a43ef5411 (patch) | |
tree | 12693d285bf6335bed4d861f932e1e174ffefc8d /engines | |
parent | f907dc7fc72594e00b48c76629b40229e76657cb (diff) | |
download | scummvm-rg350-eba5780fc062d26ba2d70d3bc438265a43ef5411.tar.gz scummvm-rg350-eba5780fc062d26ba2d70d3bc438265a43ef5411.tar.bz2 scummvm-rg350-eba5780fc062d26ba2d70d3bc438265a43ef5411.zip |
When creating a CleanupSongIterator, transfer death listeners to it
svn-id: r42113
Diffstat (limited to 'engines')
-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 */ |