1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-02 17:23:18 +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()

View File

@ -252,6 +252,8 @@ class AUDACITY_DLL_API TrackListIterator /* not final */
Track *RemoveCurrent(bool deletetrack = false); // returns next
protected:
friend TrackList;
TrackList *l;
TrackListNode *cur;
};