Lv2Ports: Smash plugins with out-of-bounds defaults
This commit is contained in:
committed by
Johannes Lorenz
parent
1c2107f4c6
commit
3a74bad0c9
@@ -42,6 +42,7 @@ enum PluginIssueType
|
||||
portHasNoDef,
|
||||
portHasNoMin,
|
||||
portHasNoMax,
|
||||
defaultValueNotInRange,
|
||||
featureNotSupported, //!< plugin requires functionality LMMS can't offer
|
||||
badPortType, //!< port type not supported
|
||||
blacklisted,
|
||||
|
||||
@@ -50,6 +50,8 @@ const char *PluginIssue::msgFor(const PluginIssueType &it)
|
||||
return "port is missing min value";
|
||||
case portHasNoMax:
|
||||
return "port is missing max value";
|
||||
case defaultValueNotInRange:
|
||||
return "default value is not in range [min, max]";
|
||||
case featureNotSupported:
|
||||
return "required feature not supported";
|
||||
case badPortType:
|
||||
|
||||
@@ -151,12 +151,35 @@ std::vector<PluginIssue> Meta::get(const LilvPlugin *plugin,
|
||||
};
|
||||
|
||||
takeRangeValue(def.get(), m_def, portHasNoDef);
|
||||
if (!isToggle)
|
||||
if (isToggle)
|
||||
{
|
||||
m_min = .0f;
|
||||
m_max = 1.f;
|
||||
if(def.get() && m_def != m_min && m_def != m_max)
|
||||
{
|
||||
issue(defaultValueNotInRange, portName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
takeRangeValue(min.get(), m_min, portHasNoMin);
|
||||
takeRangeValue(max.get(), m_max, portHasNoMax);
|
||||
if (hasProperty(LV2_CORE__sampleRate)) { m_sampleRate = true; }
|
||||
|
||||
if (def.get())
|
||||
{
|
||||
if (m_def < m_min) { issue(defaultValueNotInRange, portName); }
|
||||
else if (m_def > m_max)
|
||||
{
|
||||
if(m_sampleRate)
|
||||
{
|
||||
// multiplying with sample rate will hopefully lead us
|
||||
// to a good default value
|
||||
}
|
||||
else { issue(defaultValueNotInRange, portName); }
|
||||
}
|
||||
}
|
||||
|
||||
if (m_max - m_min > 15.0f)
|
||||
{
|
||||
// range too large for spinbox visualisation, use knobs
|
||||
|
||||
Reference in New Issue
Block a user