Fix std::optional value() build error on older macOS SDK
For old macOS (pre 10.14), std::optional does not have .value() method, so the code is using operator*() instead.
This commit is contained in:
parent
917c9ad47b
commit
8b3ff9b9c4
5 changed files with 12 additions and 12 deletions
|
@ -1689,7 +1689,7 @@ public:
|
|||
assert(this->is_valid_closed_enum());
|
||||
auto opt = this->enum_to_index(enum_val);
|
||||
return opt.has_value() ?
|
||||
std::optional<std::reference_wrapper<const std::string>>{ this->value(opt.value()) } :
|
||||
std::optional<std::reference_wrapper<const std::string>>{ this->value(*opt) } :
|
||||
std::optional<std::reference_wrapper<const std::string>>{};
|
||||
}
|
||||
|
||||
|
@ -1697,7 +1697,7 @@ public:
|
|||
assert(this->is_valid_closed_enum());
|
||||
auto opt = this->enum_to_index(enum_val);
|
||||
return opt.has_value() ?
|
||||
std::optional<std::reference_wrapper<const std::string>>{ this->label(opt.value()) } :
|
||||
std::optional<std::reference_wrapper<const std::string>>{ this->label(*opt) } :
|
||||
std::optional<std::reference_wrapper<const std::string>>{};
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
|
|||
const ConfigOptionDef *fill_pattern_def = config->option_def("fill_pattern");
|
||||
assert(fill_pattern_def != nullptr);
|
||||
if (auto label = fill_pattern_def->enum_def->enum_to_label(fill_pattern); label.has_value()) {
|
||||
wxString msg_text = GUI::format_wxstr(_L("The %1% infill pattern is not supposed to work at 100%% density."), _(label.value()));
|
||||
wxString msg_text = GUI::format_wxstr(_L("The %1% infill pattern is not supposed to work at 100%% density."), _(*label));
|
||||
if (is_global_config)
|
||||
msg_text += "\n\n" + _L("Shall I switch to rectilinear fill pattern?");
|
||||
MessageDialog dialog(m_msg_dlg_parent, msg_text, _L("Infill"),
|
||||
|
|
|
@ -1141,7 +1141,7 @@ void Choice::set_selection()
|
|||
if (!text_value.IsEmpty()) {
|
||||
if (auto opt = m_opt.enum_def->value_to_index(into_u8(text_value)); opt.has_value())
|
||||
// This enum has a value field of the same content as text_value. Select it.
|
||||
field->SetSelection(opt.value());
|
||||
field->SetSelection(*opt);
|
||||
else
|
||||
field->SetValue(text_value);
|
||||
}
|
||||
|
@ -1153,7 +1153,7 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda
|
|||
choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
|
||||
if (auto opt = m_opt.enum_def->value_to_index(value); opt.has_value())
|
||||
// This enum has a value field of the same content as text_value. Select it.
|
||||
field->SetSelection(opt.value());
|
||||
field->SetSelection(*opt);
|
||||
else
|
||||
field->SetValue(value);
|
||||
m_disable_change_event = false;
|
||||
|
@ -1178,9 +1178,9 @@ void Choice::set_value(const boost::any& value, bool change_event)
|
|||
int sel_idx = -1;
|
||||
if (m_opt.enum_def) {
|
||||
if (auto idx = m_opt.enum_def->label_to_index(into_u8(text_value)); idx.has_value())
|
||||
sel_idx = idx.value();
|
||||
sel_idx = *idx;
|
||||
else if (idx = m_opt.enum_def->value_to_index(into_u8(text_value)); idx.has_value())
|
||||
sel_idx = idx.value();
|
||||
sel_idx = *idx;
|
||||
}
|
||||
|
||||
if (sel_idx >= 0 )
|
||||
|
@ -1205,7 +1205,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
|
|||
case coEnum: {
|
||||
auto val = m_opt.enum_def->enum_to_index(boost::any_cast<int>(value));
|
||||
assert(val.has_value());
|
||||
field->SetSelection(val.has_value() ? val.value() : 0);
|
||||
field->SetSelection(val.has_value() ? *val : 0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1325,7 +1325,7 @@ void Choice::msw_rescale()
|
|||
|
||||
if (auto opt = m_opt.enum_def->label_to_index(into_u8(selection)); opt.has_value())
|
||||
// This enum has a value field of the same content as text_value. Select it.
|
||||
field->SetSelection(opt.value());
|
||||
field->SetSelection(*opt);
|
||||
else
|
||||
field->SetValue(selection);
|
||||
}
|
||||
|
|
|
@ -282,8 +282,8 @@ static void add_config_substitutions(const ConfigSubstitutions& conf_substitutio
|
|||
{
|
||||
auto opt = def->enum_def->enum_to_index(conf_substitution.new_value->getInt());
|
||||
new_val = opt.has_value() ?
|
||||
wxString("\"") + def->enum_def->value(opt.value()) + "\"" + " (" +
|
||||
_(wxString::FromUTF8(def->enum_def->label(opt.value()))) + ")" :
|
||||
wxString("\"") + def->enum_def->value(*opt) + "\"" + " (" +
|
||||
_(from_u8(def->enum_def->label(*opt))) + ")" :
|
||||
_L("Undefined");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1194,7 +1194,7 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
|
|||
}
|
||||
case coEnum: {
|
||||
auto opt = config.option_def(opt_key)->enum_def->enum_to_label(config.option(opt_key)->getInt());
|
||||
return opt.has_value() ? _(wxString::FromUTF8(opt.value())) : _L("Undef");
|
||||
return opt.has_value() ? _(from_u8(*opt)) : _L("Undef");
|
||||
}
|
||||
case coPoints: {
|
||||
if (opt_key == "bed_shape") {
|
||||
|
|
Loading…
Add table
Reference in a new issue