mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 07:39:42 +02:00
Compatibility sanity check for inserting clips into a WaveTrack...
... And don't move from the shared pointer argument
This commit is contained in:
parent
1a11b81deb
commit
d3ab8b7f76
@ -979,11 +979,16 @@ std::shared_ptr<WaveClip> WaveTrack::RemoveAndReturnClip(WaveClip* clip)
|
||||
return {};
|
||||
}
|
||||
|
||||
void WaveTrack::AddClip(std::shared_ptr<WaveClip> &&clip)
|
||||
bool WaveTrack::AddClip(const std::shared_ptr<WaveClip> &clip)
|
||||
{
|
||||
if (clip->GetSequence()->GetFactory() != this->mpFactory)
|
||||
return false;
|
||||
|
||||
// Uncomment the following line after we correct the problem of zero-length clips
|
||||
//if (CanInsertClip(clip))
|
||||
mClips.push_back(std::move(clip)); // transfer ownership
|
||||
mClips.push_back(clip); // transfer ownership
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! @excsafety{Strong} */
|
||||
|
@ -480,8 +480,8 @@ private:
|
||||
// You assume responsibility for its memory!
|
||||
std::shared_ptr<WaveClip> RemoveAndReturnClip(WaveClip* clip);
|
||||
|
||||
// Append a clip to the track
|
||||
void AddClip(std::shared_ptr<WaveClip> &&clip); // Call using std::move
|
||||
//! Append a clip to the track; which must have the same block factory as this track; return success
|
||||
bool AddClip(const std::shared_ptr<WaveClip> &clip);
|
||||
|
||||
// Merge two clips, that is append data from clip2 to clip1,
|
||||
// then remove clip2 from track.
|
||||
|
@ -201,12 +201,13 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
||||
// PRL: I don't think that matters, the sequence of storage of clips in the track
|
||||
// is not elsewhere assumed to be by time
|
||||
{
|
||||
for (auto it = revClips.rbegin(), revEnd = revClips.rend(); it != revEnd; ++it)
|
||||
track->AddClip(std::move(*it));
|
||||
for (auto it = revClips.rbegin(), revEnd = revClips.rend(); rValue && it != revEnd; ++it)
|
||||
rValue = track->AddClip(*it);
|
||||
}
|
||||
|
||||
for (auto &clip : otherClips)
|
||||
track->AddClip(std::move(clip));
|
||||
if (!(rValue = track->AddClip(clip)))
|
||||
break;
|
||||
|
||||
return rValue;
|
||||
}
|
||||
|
@ -825,7 +825,8 @@ namespace {
|
||||
WaveClip *const pSrcClip = trackClip.clip;
|
||||
if (pSrcClip) {
|
||||
const auto dstTrack = trackClip.dstTrack;
|
||||
dstTrack->AddClip(std::move(trackClip.holder));
|
||||
// To do: check and propagate the error! Can't from a dtor
|
||||
(void) dstTrack->AddClip(trackClip.holder);
|
||||
trackClip.track = dstTrack;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user