FIX: handle empty AMS filament type

Change-Id: I76b931a28fef4aaf18c2ca0a472fcbefee4663b8
This commit is contained in:
chunmao.guo 2023-06-06 09:04:03 +08:00 committed by Lane.Wei
parent dde886aae8
commit 10838680dd
3 changed files with 15 additions and 8 deletions

View file

@ -382,9 +382,12 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
auto iter = std::find_if(filaments.begin(), filaments.end(),
[&filament_id](auto &f) { return f.is_compatible && f.is_system && f.filament_id == filament_id; });
if (iter == filaments.end()) {
auto filament_type = "Generic " + tray.opt_string("filament_type", 0u);
iter = std::find_if(filaments.begin(), filaments.end(),
[&filament_type](auto &f) { return f.is_compatible && f.is_system && boost::algorithm::starts_with(f.name, filament_type); });
auto filament_type = tray.opt_string("filament_type", 0u);
if (!filament_type.empty()) {
filament_type = "Generic " + filament_type;
iter = std::find_if(filaments.begin(), filaments.end(),
[&filament_type](auto &f) { return f.is_compatible && f.is_system && boost::algorithm::starts_with(f.name, filament_type); });
}
}
if (iter == filaments.end()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % filament_id;