Fixed validation of cfg when a vector contains a nullable option which is nil for some elements but not for others #10163, SPE-1613

This commit is contained in:
Lukas Matena 2023-03-27 12:24:07 +02:00
parent 8e0b45fc83
commit c654a6714a

View file

@ -4552,12 +4552,19 @@ std::string validate(const FullPrintConfig &cfg)
}
case coFloats:
case coPercents:
for (double v : static_cast<const ConfigOptionVector<double>*>(opt)->values)
{
const auto* vec = static_cast<const ConfigOptionVector<double>*>(opt);
for (size_t i = 0; i < vec->size(); ++i) {
if (vec->is_nil(i))
continue;
double v = vec->values[i];
if (v < optdef->min || v > optdef->max) {
out_of_range = true;
break;
}
}
break;
}
case coInt:
{
auto *iopt = static_cast<const ConfigOptionInt*>(opt);
@ -4565,12 +4572,19 @@ std::string validate(const FullPrintConfig &cfg)
break;
}
case coInts:
for (int v : static_cast<const ConfigOptionVector<int>*>(opt)->values)
{
const auto* vec = static_cast<const ConfigOptionVector<int>*>(opt);
for (size_t i = 0; i < vec->size(); ++i) {
if (vec->is_nil(i))
continue;
int v = vec->values[i];
if (v < optdef->min || v > optdef->max) {
out_of_range = true;
break;
}
}
break;
}
default:;
}
if (out_of_range)