Skip to content

Commit

Permalink
fix flaot&percent open-enum fields
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Dec 29, 2023
1 parent 131679c commit 8ff918a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/slic3r/GUI/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1641,8 +1641,8 @@ void Choice::propagate_value()
switch (m_opt.type) {
case coFloatOrPercent:
{
std::string old_val = !m_value.empty() ? boost::any_cast<std::string>(m_value) : "";
if (old_val == boost::any_cast<std::string>(get_value()))
FloatOrPercent old_val = !m_value.empty() ? boost::any_cast<FloatOrPercent>(m_value) : FloatOrPercent{};
if (old_val == boost::any_cast<FloatOrPercent>(get_value()))
return;
break;
}
Expand Down Expand Up @@ -1911,9 +1911,10 @@ boost::any& Choice::get_value()
(ret_str != m_opt.enum_values[ret_enum] && ret_str != _(m_opt.enum_labels[ret_enum])))
// modifies ret_string!
get_value_by_opt_type(ret_str);
else if (m_opt.type == coFloatOrPercent)
m_value = m_opt.enum_values[ret_enum];
else if (m_opt.type == coInt)
else if (m_opt.type == coFloatOrPercent) {
m_value = FloatOrPercent{string_to_double_decimal_point(m_opt.enum_values[ret_enum]),
(m_opt.enum_values[ret_enum].find('%') != std::string::npos)};
} else if (m_opt.type == coInt)
m_value = atoi(m_opt.enum_values[ret_enum].c_str());
else
m_value = string_to_double_decimal_point(m_opt.enum_values[ret_enum]);
Expand Down

0 comments on commit 8ff918a

Please sign in to comment.