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 c0f2782695
commit e0d826a542
2 changed files with 6 additions and 35 deletions

View File

@ -792,15 +792,6 @@ std::shared_ptr<TrackList> TrackList::Create()
return result;
}
TrackList& TrackList::operator= (const TrackList &that)
{
if (this != &that) {
this->Clear();
DoAssign(that);
}
return *this;
}
TrackList &TrackList::operator= (TrackList &&that)
{
if (this != &that) {
@ -810,23 +801,6 @@ TrackList &TrackList::operator= (TrackList &&that)
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->mPendingUpdates, mSelf, that.mPendingUpdates );
mUpdaters = that.mUpdaters;
}
void TrackList::Swap(TrackList &that)
{
auto SwapLOTs = [](

View File

@ -614,8 +614,13 @@ class TrackList final : public wxEvtHandler, public ListOfTracks
// Create an empty TrackList
TrackList();
// Disallow copy
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;
@ -623,12 +628,6 @@ class TrackList final : public wxEvtHandler, public ListOfTracks
// Create an empty TrackList
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
void Swap(TrackList &that);
@ -776,8 +775,6 @@ private:
}
}
void DoAssign(const TrackList &that);
void RecalcPositions(TrackNodePointer node);
void PermutationEvent();
void DeletionEvent();