1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 08:39:46 +02:00

Bug2015: crash repeatedly append-recording with sync-lock on

This commit is contained in:
Paul Licameli 2018-10-29 20:35:45 -04:00
parent 911840074e
commit 3be57fce49
2 changed files with 33 additions and 3 deletions

View File

@ -325,13 +325,19 @@ bool Track::IsSyncLockSelected() const
auto pList = mList.lock();
if (!pList)
return false;
auto trackRange = TrackList::SyncLockGroup(this);
auto shTrack = this->SubstituteOriginalTrack();
if (!shTrack)
return false;
const auto pTrack = shTrack.get();
auto trackRange = TrackList::SyncLockGroup( pTrack );
if (trackRange.size() <= 1) {
// Not in a sync-locked group.
// Return true iff selected and of a sync-lockable type.
return (IsSyncLockableNonLabelTrack(this) ||
track_cast<const LabelTrack*>(this)) && GetSelected();
return (IsSyncLockableNonLabelTrack( pTrack ) ||
track_cast<const LabelTrack*>( pTrack )) && GetSelected();
}
// Return true iff any track in the group is selected.
@ -1377,6 +1383,26 @@ std::shared_ptr<const Track> Track::SubstitutePendingChangedTrack() const
return Pointer( this );
}
std::shared_ptr<const Track> Track::SubstituteOriginalTrack() const
{
auto pList = mList.lock();
if (pList) {
const auto id = GetId();
const auto pred = [=]( const ListOfTracks::value_type &ptr ) {
return ptr->GetId() == id; };
const auto end = pList->mPendingUpdates.end();
const auto it = std::find_if( pList->mPendingUpdates.begin(), end, pred );
if (it != end) {
const auto &list2 = (const ListOfTracks &) *pList;
const auto end2 = list2.end();
const auto it2 = std::find_if( list2.begin(), end2, pred );
if ( it2 != end2 )
return *it2;
}
}
return Pointer( this );
}
bool TrackList::HasPendingTracks() const
{
if ( !mPendingUpdates.empty() )

View File

@ -257,6 +257,10 @@ class AUDACITY_DLL_API Track /* not final */
// not yet cleared or applied; if no such exists, return this track
std::shared_ptr<const Track> SubstitutePendingChangedTrack() const;
// If this track is a pending changed track, return the corresponding
// original; else return this track
std::shared_ptr<const Track> SubstituteOriginalTrack() const;
// Cause certain overriding tool modes (Zoom; future ones?) to behave
// uniformly in all tracks, disregarding track contents.
// Do not further override this...