From c654a6714a03b2739dc82d2079b3b4a0227a5ba9 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 27 Mar 2023 12:24:07 +0200 Subject: [PATCH] Fixed validation of cfg when a vector contains a nullable option which is nil for some elements but not for others #10163, SPE-1613 --- src/libslic3r/PrintConfig.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 0089ce4571..60717b68c2 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -4552,12 +4552,19 @@ std::string validate(const FullPrintConfig &cfg) } case coFloats: case coPercents: - for (double v : static_cast*>(opt)->values) + { + const auto* vec = static_cast*>(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(opt); @@ -4565,12 +4572,19 @@ std::string validate(const FullPrintConfig &cfg) break; } case coInts: - for (int v : static_cast*>(opt)->values) + { + const auto* vec = static_cast*>(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)