From 47ee2fbef8be56b9d0ab23cd5930f3f182820554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Mon, 17 Feb 2025 13:04:42 +0100 Subject: [PATCH] SPE-2484: Fix the "Input value is out of range" error repeatedly triggered because of lost precision during the conversion of double value to float. --- src/slic3r/GUI/Field.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index fe00dd229a..d1012a8313 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -305,9 +305,11 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } } else { - show_error(m_parent, _L("Input value is out of range")); - if (m_opt.min > val) val = m_opt.min; - if (val > m_opt.max) val = m_opt.max; + if (val < (m_opt.min - EPSILON) || val > (m_opt.max + EPSILON)) { + show_error(m_parent, _L("Input value is out of range")); + } + + val = std::clamp(static_cast(val), m_opt.min, m_opt.max); set_value(double_to_string(val), true); } }