Fix paste on moved tracks with left trim

(cherry picked from commit 119a1c284639815babc8249268b10a5fe0073ea8)
Signed-off-by: Avery King <gperson@disroot.org>
This commit is contained in:
Gabriel de Freitas Sartori
2025-01-21 10:20:35 +01:00
committed by Avery King
parent 8ed0f94cd6
commit e68ca482a5

View File

@@ -1139,13 +1139,16 @@ bool WaveClip::Paste(double t0, const WaveClip& o)
ClearSequenceFinisher finisher;
//seems like edge cases cannot happen, see WaveTrack::PasteWaveTrack
double leftTrimDueToPaste = 0.0;
double pastePositionShift = 0.0;
double startPositionShift = 0.0;
auto &factory = GetFactory();
if (t0 == GetPlayStartTime())
{
pastePositionShift = t0;
startPositionShift = other.GetSequenceStartTime() + GetTrimLeft();
finisher = ClearSequence(GetSequenceStartTime(), t0);
SetTrimLeft(other.GetTrimLeft());
leftTrimDueToPaste = other.GetTrimLeft();
auto copy = std::make_shared<WaveClip>(other, factory, true);
copy->ClearSequence(copy->GetPlayEndTime(), copy->GetSequenceEndTime())
@@ -1199,7 +1202,7 @@ bool WaveClip::Paste(double t0, const WaveClip& o)
newCutlines.push_back(std::move(cutlineCopy));
}
sampleCount s0 = TimeToSequenceSamples(t0);
sampleCount s0 = TimeToSequenceSamples(t0 - pastePositionShift);
// Because newClip was made above as a copy of (a copy of) other
assert(other.NChannels() == newClip->NChannels());
@@ -1214,7 +1217,7 @@ bool WaveClip::Paste(double t0, const WaveClip& o)
transaction.Commit();
MarkChanged();
SetSequenceStartTime(GetSequenceStartTime() - leftTrimDueToPaste);
SetSequenceStartTime(GetSequenceStartTime() + startPositionShift);
const auto sampleTime = 1.0 / GetRate();
const auto timeOffsetInEnvelope =