1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-24 01:54:22 +00:00

APVTS: Fix apvts parameter update recursion

This commit is contained in:
reuk 2019-08-17 12:37:18 +01:00 committed by ed
parent 120d6cc3ff
commit d37cee72e8
2 changed files with 15 additions and 4 deletions

View file

@ -71,7 +71,9 @@ void AudioProcessorValueTreeState::Parameter::valueChanged (float newValue)
return;
lastValue = newValue;
sendValueChangedMessageToListeners (newValue);
if (onValueChanged != nullptr)
onValueChanged();
}
//==============================================================================
@ -87,6 +89,9 @@ public:
unnormalisedValue (getRange().convertFrom0to1 (parameter.getDefaultValue()))
{
parameter.addListener (this);
if (auto* ptr = dynamic_cast<Parameter*> (&parameter))
ptr->onValueChanged = [this] { parameterValueChanged ({}, {}); };
}
~ParameterAdapter() override { parameter.removeListener (this); }

View file

@ -362,6 +362,10 @@ public:
UndoManager* const undoManager;
//==============================================================================
private:
class ParameterAdapter;
public:
/** A parameter class that maintains backwards compatibility with deprecated
AudioProcessorValueTreeState functionality.
@ -416,9 +420,13 @@ public:
private:
void valueChanged (float) override;
std::function<void()> onValueChanged;
const float unsnappedDefault;
const bool metaParameter, automatable, discrete, boolean;
float lastValue = 0.0f;
float lastValue = -1.0f;
friend class AudioProcessorValueTreeState::ParameterAdapter;
};
//==============================================================================
@ -523,8 +531,6 @@ private:
bool, bool, bool, AudioProcessorParameter::Category, bool));
//==============================================================================
class ParameterAdapter;
#if JUCE_UNIT_TESTS
friend struct ParameterAdapterTests;
#endif