From 3ec17fae67cf24d934062bb3f1d817fe89e419e8 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 29 Apr 2019 11:13:32 +0200 Subject: [PATCH] A hotfix for #2179 (GCode preview crash on T-1 in GCode) --- src/slic3r/GUI/GLCanvas3D.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index bfa4a8ed62..dfddc7f452 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5001,6 +5001,10 @@ bool GLCanvas3D::_travel_paths_by_tool(const GCodePreviewData& preview_data, con // creates a new volume for each tool for (Tool& tool : tools) { + // tool.value could be invalid (as it was with https://github.com/prusa3d/Slic3r/issues/2179), we better check + if (tool.value >= tool_colors.size()) + continue; + GLVolume* volume = new GLVolume(tool_colors.data() + tool.value * 4); if (volume == nullptr) return false; @@ -5015,7 +5019,7 @@ bool GLCanvas3D::_travel_paths_by_tool(const GCodePreviewData& preview_data, con for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines) { ToolsList::iterator tool = std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id)); - if (tool != tools.end()) + if (tool != tools.end() && tool->volume != nullptr) { tool->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min(2))); tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.quad_indices.size());