FIX:Fix the issue of importing GCode array out of bounds

jira: STUDIO-12389
Change-Id: Id7995558bf0e297e2360b338ffbf63d93efa38f0
This commit is contained in:
zhou.xu 2025-05-26 21:01:24 +08:00 committed by lane.wei
parent 6ce4666886
commit 6d15a90057
3 changed files with 13 additions and 3 deletions

View File

@ -5442,6 +5442,16 @@ void GCodeProcessor::process_T(const std::string_view command)
} }
void GCodeProcessor::init_filament_maps_and_nozzle_type_when_import_only_gcode()
{
if (m_filament_maps.empty()) {
m_filament_maps.assign((int) EnforcerBlockerType::ExtruderMax, 1);
}
if (m_result.nozzle_type.empty()) {
m_result.nozzle_type.assign((int) EnforcerBlockerType::ExtruderMax, NozzleType::ntUndefine);
}
}
void GCodeProcessor::process_filament_change(int id) void GCodeProcessor::process_filament_change(int id)
{ {
assert(id < m_result.filaments_count); assert(id < m_result.filaments_count);
@ -5864,7 +5874,7 @@ void GCodeProcessor::update_slice_warnings()
warning.params.clear(); warning.params.clear();
warning.level=1; warning.level=1;
std::vector<int>nozzle_hrc_lists(m_result.nozzle_type.size(), 0); std::vector<int> nozzle_hrc_lists(m_result.nozzle_type.size(), 0);
// store the nozzle hrc of each extruder // store the nozzle hrc of each extruder
for (size_t idx = 0; idx < m_result.nozzle_type.size(); ++idx) for (size_t idx = 0; idx < m_result.nozzle_type.size(); ++idx)
nozzle_hrc_lists[idx] = Print::get_hrc_by_nozzle_type(m_result.nozzle_type[idx]); nozzle_hrc_lists[idx] = Print::get_hrc_by_nozzle_type(m_result.nozzle_type[idx]);

View File

@ -1100,7 +1100,7 @@ namespace Slic3r {
public: public:
GCodeProcessor(); GCodeProcessor();
void init_filament_maps_and_nozzle_type_when_import_only_gcode();
// check whether the gcode path meets the filament_map grouping requirements // check whether the gcode path meets the filament_map grouping requirements
bool check_multi_extruder_gcode_valid(const std::vector<Polygons> &unprintable_areas, bool check_multi_extruder_gcode_valid(const std::vector<Polygons> &unprintable_areas,
const std::vector<double> &printable_heights, const std::vector<double> &printable_heights,
@ -1296,7 +1296,6 @@ namespace Slic3r {
void process_M1020(const GCodeReader::GCodeLine &line); void process_M1020(const GCodeReader::GCodeLine &line);
void process_filament_change(int id); void process_filament_change(int id);
//BBS: different path_type is only used for arc move //BBS: different path_type is only used for arc move
void store_move_vertex(EMoveType type, EMovePathType path_type = EMovePathType::Noop_move); void store_move_vertex(EMoveType type, EMovePathType path_type = EMovePathType::Noop_move);

View File

@ -12383,6 +12383,7 @@ void Plater::load_gcode(const wxString& filename)
// process gcode // process gcode
GCodeProcessor processor; GCodeProcessor processor;
processor.init_filament_maps_and_nozzle_type_when_import_only_gcode();
try try
{ {
processor.process_file(filename.ToUTF8().data()); processor.process_file(filename.ToUTF8().data());