Fix bug 2392

Commit 66fd95f3d6 reverted.
This commit is contained in:
SteveDaulton 2020-04-16 17:33:48 +01:00
parent 7a397b57ac
commit 29d1a7b7b1
6 changed files with 26 additions and 27 deletions

View File

@ -221,7 +221,7 @@ bool EffectChangePitch::Process()
proxy.mProxyEffectName = XO("High Quality Pitch Change");
proxy.setParameters(1.0, pitchRatio);
return Delegate( proxy );
return Delegate(proxy, *mUIParent, nullptr);
}
else
#endif

View File

@ -207,7 +207,7 @@ bool EffectChangeTempo::Process()
EffectSBSMS proxy;
proxy.mProxyEffectName = XO("High Quality Tempo Change");
proxy.setParameters(tempoRatio, 1.0);
success = Delegate( proxy );
success = Delegate(proxy, *mUIParent, nullptr);
}
else
#endif

View File

@ -1320,13 +1320,14 @@ bool Effect::DoEffect(double projectRate,
return returnVal;
}
bool Effect::Delegate( Effect &delegate )
bool Effect::Delegate(
Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory )
{
NotifyingSelectedRegion region;
region.setTimes( mT0, mT1 );
return delegate.DoEffect(
mProjectRate, mTracks, mFactory, region );
return delegate.DoEffect( mProjectRate, mTracks, mFactory,
region, &parent, factory );
}
// All legacy effects should have this overridden

View File

@ -262,7 +262,8 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
wxWindow *pParent = nullptr,
const EffectDialogFactory &dialogFactory = {} );
bool Delegate( Effect &delegate );
bool Delegate( Effect &delegate,
wxWindow &parent, const EffectDialogFactory &factory );
virtual bool IsHidden();

View File

@ -544,8 +544,6 @@ bool NyquistEffect::SetAutomationParameters(CommandParameters & parms)
bool NyquistEffect::Init()
{
mDelegate.reset();
// When Nyquist Prompt spawns an effect GUI, Init() is called for Nyquist Prompt,
// and then again for the spawned (mExternal) effect.
@ -620,21 +618,17 @@ bool NyquistEffect::Init()
return true;
}
bool NyquistEffect::CheckWhetherSkipEffect()
{
// If we're a prompt and we have controls, then we've already processed
// the audio, so skip further processing.
return (mIsPrompt && mControls.size() > 0);
}
static void RegisterFunctions();
bool NyquistEffect::Process()
{
if (mDelegate)
{
mProgress->Hide();
auto &effect = *mDelegate;
auto result = Delegate( effect );
mT0 = effect.mT0;
mT1 = effect.mT1;
mDelegate.reset();
return result;
}
// Check for reentrant Nyquist commands.
// I'm choosing to mark skipped Nyquist commands as successful even though
// they are skipped. The reason is that when Nyquist calls out to a chain,
@ -654,6 +648,10 @@ bool NyquistEffect::Process()
EffectManager & em = EffectManager::Get();
em.SetSkipStateFlag(false);
if (mExternal) {
mProgress->Hide();
}
mOutputTime = 0;
mCount = 0;
mProgressIn = 0;
@ -1016,14 +1014,14 @@ bool NyquistEffect::ShowInterface(
return res;
}
// Come here only in case the user entered a script into the Nyquist
// prompt window that included the magic comments that specify controls.
// Interpret those comments and put up a second dialog.
mDelegate = std::make_unique< NyquistEffect >( NYQUIST_WORKER_ID );
auto &effect = *mDelegate;
NyquistEffect effect(NYQUIST_WORKER_ID);
effect.SetCommand(mInputCmd);
effect.mDebug = (mUIResultID == eDebugID);
return effect.ShowInterface( parent, factory, forceModal );
bool result = Delegate(effect, parent, factory);
mT0 = effect.mT0;
mT1 = effect.mT1;
return result;
}
void NyquistEffect::PopulateOrExchange(ShuttleGui & S)

View File

@ -97,6 +97,7 @@ public:
// Effect implementation
bool Init() override;
bool CheckWhetherSkipEffect() override;
bool Process() override;
bool ShowInterface( wxWindow &parent,
const EffectDialogFactory &factory, bool forceModal = false) override;
@ -188,8 +189,6 @@ private:
private:
std::unique_ptr<NyquistEffect> mDelegate;
wxString mXlispPath;
wxFileName mFileName; ///< Name of the Nyquist script file this effect is loaded from