mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
Prohibit copy of TrackList, no longer needed; allow swap and move
This commit is contained in:
parent
c0f2782695
commit
e0d826a542
@ -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 = [](
|
||||
|
15
src/Track.h
15
src/Track.h
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user