From e47349a6f43c6a96a071542fa4275572b215f7a7 Mon Sep 17 00:00:00 2001 From: "v.audacity" Date: Sat, 3 Mar 2012 20:20:06 +0000 Subject: [PATCH] Further fix for P2 bug described by Bill Wharrie in "Problem dragging clips between tracks with different sample rates" thread on audacity-quality. Moved the resampling of dragged clips to (left-)mouse-up, rather than upon drag into the destination, but still dragging. --- src/TrackPanel.cpp | 11 +++++++++++ src/WaveTrack.cpp | 4 +--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 955d5b711..dce68d0e1 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -2553,6 +2553,17 @@ void TrackPanel::HandleSlide(wxMouseEvent & event) DoSlide(event); if (event.LeftUp()) { + if (mDidSlideVertically && mCapturedTrack) + // Now that user has dropped the clip into a different track, + // make sure the sample rate matches the destination track. + for (size_t i = 0; i < mCapturedClipArray.GetCount(); i++) + if (mCapturedTrack->GetKind() == Track::Wave) // Should always be true here, but make sure. + { + WaveTrack* pWaveTrack = (WaveTrack*)mCapturedTrack; + mCapturedClipArray[i].clip->Resample(pWaveTrack->GetRate()); + mCapturedClipArray[i].clip->MarkChanged(); + } + SetCapturedTrack( NULL ); if (mSnapManager) { diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 10c8176d5..0c37ddeae 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -1852,11 +1852,9 @@ void WaveTrack::MoveClipToTrack(WaveClip *clip, WaveTrack* dest) { for (WaveClipList::compatibility_iterator it=GetClipIterator(); it; it=it->GetNext()) { if (it->GetData() == clip) { - WaveClip* clip = it->GetData(); // ANSWER-ME: Why declare and assign this to another variable, when we just verified the 'clip' parameter is the right value?! + WaveClip* clip = it->GetData(); //vvv ANSWER-ME: Why declare and assign this to another variable, when we just verified the 'clip' parameter is the right value?! mClips.DeleteNode(it); dest->mClips.Append(clip); - clip->Resample(dest->GetRate()); - clip->MarkChanged(); return; // JKC iterator is now 'defunct' so better return straight away. } }