Don't push effects that can't be undone onto the Undo Stack
This commit is contained in:
parent
159f0263f3
commit
1d6d08c47d
|
@ -608,7 +608,8 @@ bool BatchCommands::ApplyEffectCommand(const PluginID & ID, const wxString & com
|
|||
{
|
||||
// and apply the effect...
|
||||
res = project->OnEffect(ID, AudacityProject::OnEffectFlags::kConfigured |
|
||||
AudacityProject::OnEffectFlags::kSkipState);
|
||||
AudacityProject::OnEffectFlags::kSkipState |
|
||||
AudacityProject::OnEffectFlags::kDontRepeatLast);
|
||||
}
|
||||
|
||||
EffectManager::Get().SetBatchProcessing(ID, false);
|
||||
|
|
|
@ -3293,8 +3293,8 @@ void AudacityProject::OnZeroCrossing()
|
|||
|
||||
/// OnEffect() takes a PluginID and has the EffectManager execute the assocated effect.
|
||||
///
|
||||
/// At the moment flags are used only to indicate whether to prompt for parameters and
|
||||
/// whether to save the state to history.
|
||||
/// At the moment flags are used only to indicate whether to prompt for parameters,
|
||||
/// whether to save the state to history and whether to allow 'Repeat Last Effect'.
|
||||
bool AudacityProject::OnEffect(const PluginID & ID, int flags)
|
||||
{
|
||||
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
|
||||
|
@ -3360,19 +3360,26 @@ bool AudacityProject::OnEffect(const PluginID & ID, int flags)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (em.GetSkipStateFlag())
|
||||
flags = flags | OnEffectFlags::kSkipState;
|
||||
|
||||
if (!(flags & OnEffectFlags::kSkipState))
|
||||
{
|
||||
wxString shortDesc = em.GetEffectName(ID);
|
||||
wxString longDesc = em.GetEffectDescription(ID);
|
||||
PushState(longDesc, shortDesc);
|
||||
}
|
||||
|
||||
if (!(flags & OnEffectFlags::kDontRepeatLast))
|
||||
{
|
||||
// Only remember a successful effect, don't rmemeber insert,
|
||||
// or analyze effects.
|
||||
if (type == EffectTypeProcess) {
|
||||
wxString shortDesc = em.GetEffectName(ID);
|
||||
mLastEffect = ID;
|
||||
wxString lastEffectDesc;
|
||||
/* i18n-hint: %s will be the name of the effect which will be
|
||||
* repeated if this menu item is chosen */
|
||||
* repeated if this menu item is chosen */
|
||||
lastEffectDesc.Printf(_("Repeat %s"), shortDesc.c_str());
|
||||
mCommandManager.Modify(wxT("RepeatLastEffect"), lastEffectDesc);
|
||||
}
|
||||
|
|
|
@ -369,6 +369,8 @@ public:
|
|||
static const int kConfigured = 0x01;
|
||||
// Flag used to disable saving the state after processing.
|
||||
static const int kSkipState = 0x02;
|
||||
// Flag used to disable "Repeat Last Effect"
|
||||
static const int kDontRepeatLast = 0x04;
|
||||
};
|
||||
|
||||
bool OnEffect(const PluginID & ID, int flags = OnEffectFlags::kNone);
|
||||
|
|
|
@ -42,6 +42,7 @@ EffectManager::EffectManager()
|
|||
mRealtimeSuspended = true;
|
||||
mRealtimeLatency = 0;
|
||||
mRealtimeLock.Leave();
|
||||
mSkipStateFlag = false;
|
||||
|
||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||
mRack = NULL;
|
||||
|
@ -92,6 +93,7 @@ bool EffectManager::DoEffect(const PluginID & ID,
|
|||
bool shouldPrompt /* = true */)
|
||||
|
||||
{
|
||||
this->SetSkipStateFlag(false);
|
||||
Effect *effect = GetEffect(ID);
|
||||
|
||||
if (!effect)
|
||||
|
@ -171,6 +173,16 @@ bool EffectManager::IsHidden(const PluginID & ID)
|
|||
return false;
|
||||
}
|
||||
|
||||
void EffectManager::SetSkipStateFlag(bool flag)
|
||||
{
|
||||
mSkipStateFlag = flag;
|
||||
}
|
||||
|
||||
bool EffectManager::GetSkipStateFlag()
|
||||
{
|
||||
return mSkipStateFlag;
|
||||
}
|
||||
|
||||
bool EffectManager::SupportsAutomation(const PluginID & ID)
|
||||
{
|
||||
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
|
||||
|
|
|
@ -91,7 +91,11 @@ public:
|
|||
wxString GetDefaultPreset(const PluginID & ID);
|
||||
void SetBatchProcessing(const PluginID & ID, bool start);
|
||||
|
||||
// Realtime effect processing
|
||||
/** Allow effects to disable saving the state at run time */
|
||||
void SetSkipStateFlag(bool flag);
|
||||
bool GetSkipStateFlag();
|
||||
|
||||
// Realtime effect processing
|
||||
bool RealtimeIsActive();
|
||||
bool RealtimeIsSuspended();
|
||||
void RealtimeAddEffect(Effect *effect);
|
||||
|
@ -135,6 +139,10 @@ private:
|
|||
wxArrayInt mRealtimeChans;
|
||||
wxArrayDouble mRealtimeRates;
|
||||
|
||||
// Set true if we want to skip pushing state
|
||||
// after processing at effect run time.
|
||||
bool mSkipStateFlag;
|
||||
|
||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||
EffectRack *mRack;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "../Audacity.h"
|
||||
#include "../Experimental.h"
|
||||
#include "NoiseReduction.h"
|
||||
#include "EffectManager.h"
|
||||
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../Prefs.h"
|
||||
|
@ -1616,6 +1617,9 @@ void EffectNoiseReduction::Dialog::EnableDisableSensitivityControls()
|
|||
|
||||
void EffectNoiseReduction::Dialog::OnGetProfile(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
// Project has not be changed so skip pushing state
|
||||
EffectManager::Get().SetSkipStateFlag(true);
|
||||
|
||||
if (!TransferDataFromWindow())
|
||||
return;
|
||||
|
||||
|
|
|
@ -437,6 +437,9 @@ bool NyquistEffect::CheckWhetherSkipEffect()
|
|||
bool NyquistEffect::Process()
|
||||
{
|
||||
bool success = true;
|
||||
mProjectChanged = false;
|
||||
EffectManager & em = EffectManager::Get();
|
||||
em.SetSkipStateFlag(false);
|
||||
|
||||
if (mExternal) {
|
||||
mProgress->Hide();
|
||||
|
@ -622,6 +625,8 @@ bool NyquistEffect::Process()
|
|||
if (mCurLen > NYQ_MAX_LEN) {
|
||||
wxMessageBox(_("Selection too long for Nyquist code.\nMaximum allowed selection is 2147483647 samples\n(about 13.5 hours at 44100 Hz sample rate)."),
|
||||
_("Nyquist Error"), wxOK | wxCENTRE);
|
||||
if (!mProjectChanged)
|
||||
em.SetSkipStateFlag(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -721,6 +726,9 @@ bool NyquistEffect::Process()
|
|||
|
||||
mDebug = false;
|
||||
|
||||
if (!mProjectChanged)
|
||||
em.SetSkipStateFlag(true);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -1091,6 +1099,7 @@ bool NyquistEffect::ProcessOne()
|
|||
}
|
||||
|
||||
if (rval == nyx_labels) {
|
||||
mProjectChanged = true;
|
||||
unsigned int numLabels = nyx_get_num_labels();
|
||||
unsigned int l;
|
||||
LabelTrack *ltrack = NULL;
|
||||
|
@ -1233,7 +1242,7 @@ bool NyquistEffect::ProcessOne()
|
|||
delete mOutputTrack[i];
|
||||
mOutputTrack[i] = NULL;
|
||||
}
|
||||
|
||||
mProjectChanged = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -199,6 +199,7 @@ private:
|
|||
bool mEnablePreview;
|
||||
bool mDebug;
|
||||
bool mRedirectOutput;
|
||||
bool mProjectChanged;
|
||||
wxString mDebugOutput;
|
||||
|
||||
int mVersion;
|
||||
|
|
Loading…
Reference in New Issue