From 0e287db4c9b8d9cf8817badff82057d163608dcd Mon Sep 17 00:00:00 2001 From: "v.audacity" Date: Mon, 20 Aug 2012 20:26:42 +0000 Subject: [PATCH] Turns out the failsafe I added yesterday in r11929 was the correct solution to bug 367. This commit just adjusts the comments. This also has the fix for bug 232, derived from the patch by Gaurav Agarwal. Also changed several lingering "linking" comments to "sync-lock", the agreed on current terminology. --- src/Menus.cpp | 7 +++++-- src/Track.h | 2 +- src/TrackPanel.cpp | 20 +++++++++----------- src/toolbars/ToolManager.cpp | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Menus.cpp b/src/Menus.cpp index 7a5b66de4..50033144c 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -3830,7 +3830,7 @@ void AudacityProject::OnPaste() ((LabelTrack *)n)->Clear(t0, t1); // To be (sort of) consistent with Clear behavior, we'll only shift - // them if linking is on + // them if sync-lock is on. if (IsSyncLocked()) ((LabelTrack *)n)->ShiftLabelsOnInsert(msClipT1 - msClipT0, t0); @@ -3908,7 +3908,7 @@ void AudacityProject::OnPaste() { ((LabelTrack *)n)->Clear(t0, t1); - // As above, only shift labels if linking is on + // As above, only shift labels if sync-lock is on. if (IsSyncLocked()) ((LabelTrack *)n)->ShiftLabelsOnInsert(msClipT1 - msClipT0, t0); } @@ -5330,6 +5330,9 @@ void AudacityProject::OnSelectionSave() void AudacityProject::OnSelectionRestore() { + if ((mSel0save == 0.0) && (mSel1save == 0.0)) + return; + mViewInfo.sel0 = mSel0save; mViewInfo.sel1 = mSel1save; diff --git a/src/Track.h b/src/Track.h index 4ad0391c6..0eb5302d6 100644 --- a/src/Track.h +++ b/src/Track.h @@ -184,7 +184,7 @@ class AUDACITY_DLL_API Track: public XMLTagHandler virtual double GetStartTime() { return 0.0; } virtual double GetEndTime() { return 0.0; } - // Checks if linking is on and any track in its sync-lock group is selected. + // Checks if sync-lock is on and any track in its sync-lock group is selected. bool IsSyncLockSelected(); }; diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 2da905be5..e99c06204 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -2565,20 +2565,18 @@ void TrackPanel::HandleSlide(wxMouseEvent & 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. + // make sure the sample rate matches the destination track (mCapturedTrack). 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; WaveClip* pWaveClip = mCapturedClipArray[i].clip; - //vvvvv FIX-ME: I think that at this point, mCapturedClipArray has - // the wrong clips if we're dragging a clip to another track, per bug 367. - // Probably, mCapturedClipArray does not match mCapturedTrack. - // Then if the mCapturedClipArray.GetCount() is wrong, pWaveClip can be NULL. - // This conditional is just a failsafe against crash on NULL deref. + // 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(pWaveTrack->GetRate()); + pWaveClip->Resample(((WaveTrack*)mCapturedTrack)->GetRate()); pWaveClip->MarkChanged(); } } @@ -2700,12 +2698,12 @@ void TrackPanel::StartSlide(wxMouseEvent & event) } } - // Now, if linking is enabled, capture any clip that's linked to a - // captured clip + // Now, if sync-lock is enabled, capture any clip that's linked to a + // captured clip. if (GetProject()->IsSyncLocked()) { // AWD: mCapturedClipArray expands as the loop runs, so newly-added // clips are considered (the effect is like recursion and terminates - // because AddClipsToCapture doesn't add duplicate clips); to remove + // because AddClipsToCaptured doesn't add duplicate clips); to remove // this behavior just store the array size beforehand. for (unsigned int i = 0; i < mCapturedClipArray.GetCount(); ++i) { // Capture based on tracks that have clips -- that means we diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index 88600c84c..35e49a8fe 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -602,7 +602,7 @@ void ToolManager::ReadConfig() bar->Layout(); } #else - // note that this section is here because if you had been using linking and now you aren't, + // note that this section is here because if you had been using sync-lock and now you aren't, // the space for the extra button is stored in audacity.cfg, and so you get an extra space // in the EditToolbar. // It is needed so that the meterToolbar size gets preserved.