diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index e2a3d0fd7..d30ec70b5 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -598,9 +598,6 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) } } - // ensure at least one (default) color is defined - std::string default_color = "#FF8000"; - m_result.extruder_colors = std::vector(1, default_color); const ConfigOptionStrings* extruder_colour = config.option("extruder_colour"); if (extruder_colour != nullptr) { // takes colors from config @@ -615,7 +612,9 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) } } + // replace missing values with default + std::string default_color = "#FF8000"; for (size_t i = 0; i < m_result.extruder_colors.size(); ++i) { if (m_result.extruder_colors[i].empty()) m_result.extruder_colors[i] = default_color; @@ -837,10 +836,6 @@ void GCodeProcessor::process_file(const std::string& filename, bool apply_postpr update_estimated_times_stats(); - // ensure at least one (default) color is defined - if (m_result.extruder_colors.empty()) - m_result.extruder_colors.push_back("#FF8000"); - // post-process to add M73 lines into the gcode if (apply_postprocess) m_time_processor.post_process(filename); diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 4a4a8e90e..7101ee811 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -373,6 +373,10 @@ void GCodeViewer::refresh(const GCodeProcessor::Result& gcode_result, const std: // update tool colors m_tool_colors = decode_colors(str_tool_colors); + // ensure at least one (default) color is defined + if (m_tool_colors.empty()) + m_tool_colors.push_back(decode_color("#FF8000")); + // update ranges for coloring / legend m_extrusions.reset_ranges(); for (size_t i = 0; i < m_moves_count; ++i) {