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

jira: STUDIO-12389
Change-Id: Id7995558bf0e297e2360b338ffbf63d93efa38f0
(cherry picked from commit 6d15a9005769a7dbfb96bb28ce6b57e55bf1c435)
This commit is contained in:
zhou.xu 2025-05-26 21:01:24 +08:00 committed by Noisyfox
parent 38ad17ffbe
commit adeb3ab3f7
3 changed files with 13 additions and 2 deletions

View file

@ -5436,6 +5436,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)
{
assert(id < m_result.filaments_count);
@ -5811,7 +5821,7 @@ void GCodeProcessor::update_slice_warnings()
warning.params.clear();
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
for (size_t idx = 0; idx < m_result.nozzle_type.size(); ++idx) {
nozzle_hrc_lists[idx] = m_result.nozzle_hrc;

View file

@ -838,7 +838,7 @@ class Print;
public:
GCodeProcessor();
void init_filament_maps_and_nozzle_type_when_import_only_gcode();
// check whether the gcode path meets the filament_map grouping requirements
bool check_multi_extruder_gcode_valid(const std::vector<Polygons> &unprintable_areas,
const std::vector<double> &printable_heights,

View file

@ -12324,6 +12324,7 @@ void Plater::load_gcode(const wxString& filename)
// process gcode
GCodeProcessor processor;
processor.init_filament_maps_and_nozzle_type_when_import_only_gcode();
try
{
GCodeProcessor::s_IsBBLPrinter = wxGetApp().preset_bundle->is_bbl_vendor();