Browse Source

APVTS: Avoid calling null function when unspecified

v7.0.9
reuk 2 years ago
parent
commit
34341bc597
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h

+ 9
- 1
modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h View File

@@ -498,7 +498,7 @@ public:
valueRange,
defaultParameterValue,
AudioProcessorValueTreeStateParameterAttributes().withLabel (labelText)
.withStringFromValueFunction ([valueToTextFunction] (float v, int) { return valueToTextFunction (v); })
.withStringFromValueFunction (adaptSignature (std::move (valueToTextFunction)))
.withValueFromStringFunction (std::move (textToValueFunction))
.withMeta (isMetaParameter)
.withAutomatable (isAutomatableParameter)
@@ -515,6 +515,14 @@ public:
bool isBoolean() const override;
private:
static std::function<String (float, int)> adaptSignature (std::function<String (float)> func)
{
if (func == nullptr)
return nullptr;
return [func = std::move (func)] (float v, int) { return func (v); };
}
void valueChanged (float) override;
std::function<void()> onValueChanged;


Loading…
Cancel
Save