From 57c50ff9ac387da70b882b80b88c47f7503478a0 Mon Sep 17 00:00:00 2001 From: James Crook Date: Wed, 14 Feb 2018 18:28:36 +0000 Subject: [PATCH] Nyquist can now make a selection and not have it overwritten by Effect. --- src/commands/SelectCommand.cpp | 9 +++++++++ src/effects/Effect.cpp | 2 +- src/effects/Effect.h | 2 ++ src/effects/nyquist/Nyquist.cpp | 4 +++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/commands/SelectCommand.cpp b/src/commands/SelectCommand.cpp index 1ac3cc849..d7e910620 100644 --- a/src/commands/SelectCommand.cpp +++ b/src/commands/SelectCommand.cpp @@ -61,6 +61,10 @@ bool SelectTimeCommand::Apply(const CommandContext & context){ if( !bHasT0 && !bHasT1 ) return true; + // Count selection as a do-nothing effect. + // Used to invalidate cached selection and tracks. + Effect::IncEffectCounter(); + if( mFromEnd ){ double TEnd = context.GetProject()->GetTracks()->GetEndTime(); context.GetProject()->mViewInfo.selectedRegion.setTimes(TEnd - mT0, TEnd - mT1); @@ -110,6 +114,11 @@ bool SelectTracksCommand::Apply(const CommandContext &context) { if( !bHasFirstTrack && !bHasLastTrack ) return true; + + // Count selection as a do-nothing effect. + // Used to invalidate cached selection and tracks. + Effect::IncEffectCounter(); + int index = 0; TrackList *tracks = context.GetProject()->GetTracks(); int last = wxMax( mFirstTrack, mLastTrack ); diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 3b9286c7e..a0b46e2cd 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1266,7 +1266,7 @@ bool Effect::DoEffect(wxWindow *parent, returnVal = Process(); } - if (returnVal) + if (returnVal && (mT1 >= mT0 )) { selectedRegion->setTimes(mT0, mT1); } diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 867828d99..b876c874e 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -269,6 +269,8 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, long style = DefaultMessageBoxStyle, const wxString& titleStr = wxString{}); + static void IncEffectCounter(){ nEffectsDone++;}; + // // protected virtual methods // diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index a16e5bc32..2b9cae792 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -859,8 +859,10 @@ _("Selection too long for Nyquist code.\nMaximum allowed selection is %ld sample // Has rug been pulled from under us by some effect done within Nyquist?? if( nEffectsSoFar == nEffectsDone ) ReplaceProcessedTracks(success); - else + else{ ReplaceProcessedTracks(false); // Do not use the results. + mT1 = mT0 - 1.0;// And don't use the times either, in resetting the selection (make them bogus). + } if (!mProjectChanged) em.SetSkipStateFlag(true);