1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-25 15:53:52 +02:00

Correct TrackList::Swap -- mind the back-pointers in the tracks.

This commit is contained in:
Paul Licameli
2016-03-14 11:18:32 -04:00
parent 4cf9e0e6d6
commit c609af3bbe
2 changed files with 18 additions and 0 deletions

View File

@@ -754,6 +754,22 @@ void TrackList::Swap(TrackList &that)
std::swap(mDestructorDeletesTracks, that.mDestructorDeletesTracks);
std::swap(head, that.head);
std::swap(tail, that.tail);
{
TrackListIterator iter(this);
for (Track *t = iter.First(); t; t = iter.Next()) {
t->SetOwner(NULL, NULL);
t->SetOwner(this, iter.cur);
}
}
{
TrackListIterator iter(&that);
for (Track *t = iter.First(); t; t = iter.Next()) {
t->SetOwner(NULL, NULL);
t->SetOwner(&that, iter.cur);
}
}
}
TrackList::~TrackList()