1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-30 00:18:45 +01:00

static overloads of Track::SharedPointer when null check is needed...

... Some optimizing compilers don't let us get away with null check on this
in a nonstatic member function.
This commit is contained in:
Paul Licameli
2019-03-23 13:23:46 -04:00
parent 1af342ff64
commit bb634614e6
6 changed files with 15 additions and 8 deletions

View File

@@ -238,7 +238,6 @@ class AUDACITY_DLL_API Track /* not final */
{
// shared_from_this is injected into class scope by base class
// std::enable_shared_from_this<Track>
if (!this) return {};
return std::static_pointer_cast<Subclass>( shared_from_this() );
}
@@ -250,10 +249,18 @@ class AUDACITY_DLL_API Track /* not final */
{
// shared_from_this is injected into class scope by base class
// std::enable_shared_from_this<Track>
if (!this) return {};
return std::static_pointer_cast<Subclass>( shared_from_this() );
}
// Static overloads of SharedPointer for when the pointer may be null
template<typename Subclass = Track>
static inline std::shared_ptr<Subclass> SharedPointer( Track *pTrack )
{ return pTrack ? pTrack->SharedPointer<Subclass>() : nullptr; }
template<typename Subclass = const Track>
static inline std::shared_ptr<Subclass> SharedPointer( const Track *pTrack )
{ return pTrack ? pTrack->SharedPointer<Subclass>() : nullptr; }
// Find anything registered with TrackList::RegisterPendingChangedTrack and
// not yet cleared or applied; if no such exists, return this track
std::shared_ptr<const Track> SubstitutePendingChangedTrack() const;