FIX: handle empty AMS filament type
Change-Id: I76b931a28fef4aaf18c2ca0a472fcbefee4663b8
This commit is contained in:
parent
dde886aae8
commit
10838680dd
3 changed files with 15 additions and 8 deletions
|
@ -1462,10 +1462,14 @@ unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns)
|
|||
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()) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % filament_id;
|
||||
auto filament_type = "Generic " + ams.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 = ams.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())
|
||||
iter = std::find_if(filaments.begin(), filaments.end(), [&filament_type](auto &f) { return f.is_compatible && f.is_system; });
|
||||
if (iter == filaments.end())
|
||||
|
|
|
@ -1468,7 +1468,7 @@ void Sidebar::sync_ams_list()
|
|||
wxGetApp().app_config ->set("ams_filament_ids", p->ams_list_device, ams_filament_ids);
|
||||
if (unknowns > 0) {
|
||||
MessageDialog dlg(this,
|
||||
_L("There are some unknown filaments mapped to generic preset. Please update Bambu Studio or restart Bambu Studio to check if there is an update to system presets."),
|
||||
_L("There are some unknown or uncompatible filaments mapped to generic preset. Please update Bambu Studio or restart Bambu Studio to check if there is an update to system presets."),
|
||||
_L("Sync filaments with AMS"), wxOK);
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue