mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 10:32:20 +00:00
FIX: crash of filament group in cli mode
1. Add protection for building machine filaments.Sometimes we don't know the info about maahcine filament jira:NONE Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I3198d3a1a8825aa50aa49734f60a32620fc4f890 (cherry picked from commit 0c60cefe5e188ba966f4c254f833ae81bc5da476)
This commit is contained in:
@@ -79,14 +79,21 @@ namespace FilamentGroupUtils
|
||||
auto& arr = filament_configs[idx];
|
||||
for (auto& item : arr) {
|
||||
FilamentInfo temp;
|
||||
std::string color_str = item.option<ConfigOptionStrings>("filament_colour")->get_at(0);
|
||||
if (color_str.empty())
|
||||
temp.color = Color();
|
||||
else
|
||||
temp.color = Color(color_str);
|
||||
temp.type = item.option<ConfigOptionStrings>("filament_type")->get_at(0);
|
||||
std::string type = "PLA";
|
||||
std::string color = "#FFFFFF";
|
||||
std::string tray_name;
|
||||
|
||||
if (auto color_ptr = item.option<ConfigOptionStrings>("filament_colour"); color_ptr)
|
||||
color = color_ptr->get_at(0);
|
||||
if (auto type_ptr = item.option<ConfigOptionStrings>("filament_type"); type_ptr)
|
||||
type = type_ptr->get_at(0);
|
||||
if (auto tray_ptr = item.option<ConfigOptionStrings>("tray_name"); tray_ptr)
|
||||
tray_name = tray_ptr->get_at(0);
|
||||
|
||||
temp.color = color.empty() ? Color() : Color(color);
|
||||
temp.type =type;
|
||||
temp.extruder_id = idx;
|
||||
temp.is_extended = item.option<ConfigOptionStrings>("tray_name")->get_at(0) == "Ext"; // hard-coded ext flag
|
||||
temp.is_extended = tray_name == "Ext"; // hard-coded ext flag
|
||||
machine_filaments[idx].emplace_back(std::move(temp));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user