1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Reimplement Track::Pointer using std::enable_shared_from_this...

... now the Track need not be owned yet by a TrackList
This commit is contained in:
Paul Licameli
2018-11-18 20:50:24 -05:00
parent 3dba70120c
commit 6f89c48873
19 changed files with 74 additions and 73 deletions

View File

@@ -105,7 +105,7 @@ void Track::SetSelected(bool s)
mSelected = s;
auto pList = mList.lock();
if (pList)
pList->SelectionEvent( Pointer( this ) );
pList->SelectionEvent( SharedPointer() );
}
}
@@ -351,7 +351,7 @@ void Track::Notify( int code )
{
auto pList = mList.lock();
if (pList)
pList->DataEvent( Pointer(this), code );
pList->DataEvent( SharedPointer(), code );
}
void Track::SyncLockAdjust(double oldT1, double newT1)
@@ -374,7 +374,7 @@ void Track::SyncLockAdjust(double oldT1, double newT1)
std::shared_ptr<Track> Track::FindTrack()
{
return Pointer( this );
return SharedPointer();
}
void PlayableTrack::Init( const PlayableTrack &orig )
@@ -1162,7 +1162,8 @@ namespace {
if ( ! includeMuted )
subRange = subRange - &Type::GetMute;
return transform_range<Array>( subRange.begin(), subRange.end(),
[]( Type *t ){ return Track::Pointer<Type>( t ); } );
[]( Type *t ){ return t->template SharedPointer<Type>(); }
);
}
}
@@ -1375,7 +1376,7 @@ std::shared_ptr<const Track> Track::SubstitutePendingChangedTrack() const
if (it != end)
return *it;
}
return Pointer( this );
return SharedPointer();
}
std::shared_ptr<const Track> Track::SubstituteOriginalTrack() const
@@ -1395,7 +1396,7 @@ std::shared_ptr<const Track> Track::SubstituteOriginalTrack() const
return *it2;
}
}
return Pointer( this );
return SharedPointer();
}
bool TrackList::HasPendingTracks() const