fix is_extruder_used (#1422)

This commit is contained in:
Dylan 2023-06-25 15:18:56 +08:00 committed by GitHub
parent 3fee164058
commit e925db8c0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1728,7 +1728,11 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
//m_placeholder_parser.set("has_single_extruder_multi_material_priming", has_wipe_tower && print.config().single_extruder_multi_material_priming); //m_placeholder_parser.set("has_single_extruder_multi_material_priming", has_wipe_tower && print.config().single_extruder_multi_material_priming);
m_placeholder_parser.set("total_toolchanges", std::max(0, print.wipe_tower_data().number_of_toolchanges)); // Check for negative toolchanges (single extruder mode) and set to 0 (no tool change). m_placeholder_parser.set("total_toolchanges", std::max(0, print.wipe_tower_data().number_of_toolchanges)); // Check for negative toolchanges (single extruder mode) and set to 0 (no tool change).
std::vector<unsigned char> is_extruder_used(print.config().filament_diameter.size(), 0); // PlaceholderParser currently substitues non-existent vector values with the zero'th value, which is harmful in the
// case of "is_extruder_used[]" as Slicer may lie about availability of such non-existent extruder. We rather
// sacrifice 256B of memory before we change the behavior of the PlaceholderParser, which should really only fill in
// the non-existent vector elements for filament parameters.
std::vector<unsigned char> is_extruder_used(std::max(size_t(255), print.config().filament_diameter.size()), 0);
for (unsigned int extruder : tool_ordering.all_extruders()) for (unsigned int extruder : tool_ordering.all_extruders())
is_extruder_used[extruder] = true; is_extruder_used[extruder] = true;
m_placeholder_parser.set("is_extruder_used", new ConfigOptionBools(is_extruder_used)); m_placeholder_parser.set("is_extruder_used", new ConfigOptionBools(is_extruder_used));