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.

This commit is contained in:
Lukáš Hejl 2025-02-17 13:04:42 +01:00 committed by Lukas Matena
parent 4260d76936
commit 47ee2fbef8

View File

@ -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<float>(val), m_opt.min, m_opt.max);
set_value(double_to_string(val), true);
}
}