mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Bug2127: Record, Pause, Record, Pause, Close button: shouldn't crash
This commit is contained in:
parent
6aba4a3fc7
commit
c50acea328
@ -1183,7 +1183,7 @@ bool TrackList::ApplyPendingTracks()
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<const Track> Track::SubstitutePendingChangedTrack() const
|
||||
std::shared_ptr<Track> Track::SubstitutePendingChangedTrack()
|
||||
{
|
||||
// Linear search. Tracks in a project are usually very few.
|
||||
auto pList = mList.lock();
|
||||
@ -1199,6 +1199,11 @@ std::shared_ptr<const Track> Track::SubstitutePendingChangedTrack() const
|
||||
return SharedPointer();
|
||||
}
|
||||
|
||||
std::shared_ptr<const Track> Track::SubstitutePendingChangedTrack() const
|
||||
{
|
||||
return const_cast<Track*>(this)->SubstitutePendingChangedTrack();
|
||||
}
|
||||
|
||||
std::shared_ptr<const Track> Track::SubstituteOriginalTrack() const
|
||||
{
|
||||
auto pList = mList.lock();
|
||||
|
@ -252,6 +252,7 @@ class AUDACITY_DLL_API Track /* not final */
|
||||
|
||||
// Find anything registered with TrackList::RegisterPendingChangedTrack and
|
||||
// not yet cleared or applied; if no such exists, return this track
|
||||
std::shared_ptr<Track> SubstitutePendingChangedTrack();
|
||||
std::shared_ptr<const Track> SubstitutePendingChangedTrack() const;
|
||||
|
||||
// If this track is a pending changed track, return the corresponding
|
||||
|
@ -154,10 +154,11 @@ UIHandle::Result CloseButtonHandle::CommitChanges
|
||||
auto pTrack = mpTrack.lock();
|
||||
if (pTrack)
|
||||
{
|
||||
auto toRemove = pTrack->SubstitutePendingChangedTrack();
|
||||
TransportActions::StopIfPaused( *pProject );
|
||||
if (!ProjectAudioIO::Get( *pProject ).IsAudioActive()) {
|
||||
// This pushes an undo item:
|
||||
TrackUtilities::DoRemoveTrack(*pProject, pTrack.get());
|
||||
TrackUtilities::DoRemoveTrack(*pProject, toRemove.get());
|
||||
// Redraw all tracks when any one of them closes
|
||||
// (Could we invent a return code that draws only those at or below
|
||||
// the affected track?)
|
||||
|
Loading…
x
Reference in New Issue
Block a user