From 17bfd6cfde87653c2636d3ab40caf69b2815a38b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 8 Aug 2015 18:16:48 -0400 Subject: [PATCH] Bug829: Only the clips that really moved vertically should change their rate --- src/Snap.h | 3 ++- src/TrackPanel.cpp | 34 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/Snap.h b/src/Snap.h index b95a0cb14..284a0e7cf 100644 --- a/src/Snap.h +++ b/src/Snap.h @@ -30,8 +30,9 @@ class ZoomInfo; class TrackClip { public: - TrackClip(Track *t, WaveClip *c) { track = t; clip = c; } + TrackClip(Track *t, WaveClip *c) { track = origTrack = t; clip = c; } Track *track; + Track *origTrack; WaveClip *clip; }; diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 671ea7131..65d2e7a5c 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -3836,23 +3836,23 @@ 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 (mCapturedTrack). - for (size_t i = 0; i < mCapturedClipArray.size(); i++) - if (mCapturedTrack->GetKind() == Track::Wave) // Should always be true here, but make sure. - { - WaveClip* pWaveClip = mCapturedClipArray[i].clip; - // Note that per TrackPanel::AddClipsToCaptured(Track *t, double t0, double t1), - // in the non-WaveTrack case, the code adds a NULL clip to mCapturedClipArray, - // so we have to check for that any time we're going to deref it. - // Previous code did not check it here, and that caused bug 367 crash. - if (pWaveClip) - { - pWaveClip->Resample(((WaveTrack*)mCapturedTrack)->GetRate()); - pWaveClip->MarkChanged(); - } - } + for (size_t i = 0; i < mCapturedClipArray.size(); i++) + { + TrackClip &trackClip = mCapturedClipArray[i]; + WaveClip* pWaveClip = trackClip.clip; + // Note that per TrackPanel::AddClipsToCaptured(Track *t, double t0, double t1), + // in the non-WaveTrack case, the code adds a NULL clip to mCapturedClipArray, + // so we have to check for that any time we're going to deref it. + // Previous code did not check it here, and that caused bug 367 crash. + if (pWaveClip && + trackClip.track != trackClip.origTrack) + { + // Now that user has dropped the clip into a different track, + // make sure the sample rate matches the destination track (mCapturedTrack). + pWaveClip->Resample(static_cast(trackClip.track)->GetRate()); + pWaveClip->MarkChanged(); + } + } SetCapturedTrack( NULL );