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

APVTS: Avoid calling null function when unspecified

This commit is contained in:
reuk 2022-08-30 13:37:34 +01:00
parent 8ec8e36f5c
commit 34341bc597
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

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;