1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-18 17:10:55 +02:00

Prohibit copy of TrackList, no longer needed; allow swap and move

This commit is contained in:
Paul Licameli 2018-01-10 23:58:36 -05:00
parent 91f5446eb1
commit 2409d46d4c
2 changed files with 6 additions and 36 deletions

View File

@ -792,15 +792,6 @@ std::shared_ptr<TrackList> TrackList::Create()
return result; return result;
} }
TrackList& TrackList::operator= (const TrackList &that)
{
if (this != &that) {
this->Clear();
DoAssign(that);
}
return *this;
}
TrackList &TrackList::operator= (TrackList &&that) TrackList &TrackList::operator= (TrackList &&that)
{ {
if (this != &that) { if (this != &that) {
@ -810,24 +801,6 @@ TrackList &TrackList::operator= (TrackList &&that)
return *this; return *this;
} }
void TrackList::DoAssign(const TrackList &that)
{
auto copyLOT = [](
ListOfTracks &dst, const std::weak_ptr< TrackList > &self,
const ListOfTracks &src )
{
for (const auto &ptr : src)
dst.push_back(
ListOfTracks::value_type{ ptr->Duplicate().release() } );
for (auto it = dst.begin(), last = dst.end(); it != last; ++it)
(*it)->SetOwner(self, it);
};
copyLOT( *this, mSelf, that );
copyLOT( this->mPendingAdditions, mSelf, that.mPendingAdditions );
copyLOT( this->mPendingUpdates, mSelf, that.mPendingUpdates );
mUpdaters = that.mUpdaters;
}
void TrackList::Swap(TrackList &that) void TrackList::Swap(TrackList &that)
{ {
auto SwapLOTs = []( auto SwapLOTs = [](

View File

@ -659,8 +659,13 @@ class TrackList final : public wxEvtHandler, public ListOfTracks
// Create an empty TrackList // Create an empty TrackList
TrackList(); TrackList();
// Disallow copy
TrackList(const TrackList &that) = delete; TrackList(const TrackList &that) = delete;
TrackList(TrackList &&that) = delete; TrackList &operator= (const TrackList&) = delete;
// Allow move
TrackList(TrackList &&that) : TrackList() { Swap(that); }
TrackList& operator= (TrackList&&);
void clear() = delete; void clear() = delete;
@ -668,12 +673,6 @@ class TrackList final : public wxEvtHandler, public ListOfTracks
// Create an empty TrackList // Create an empty TrackList
static std::shared_ptr<TrackList> Create(); static std::shared_ptr<TrackList> Create();
// Allow copy -- a deep copy that duplicates all tracks
TrackList &operator= (const TrackList &that);
// Allow move
TrackList& operator= (TrackList&&);
// Move is defined in terms of Swap // Move is defined in terms of Swap
void Swap(TrackList &that); void Swap(TrackList &that);
@ -831,8 +830,6 @@ private:
} }
} }
void DoAssign(const TrackList &that);
void RecalcPositions(TrackNodePointer node); void RecalcPositions(TrackNodePointer node);
void PermutationEvent(); void PermutationEvent();
void DeletionEvent(); void DeletionEvent();