mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-15 22:35:58 +08:00
Fix crash when gcode data is not valid
and comment a problematic assert that get trigger are startup
This commit is contained in:
parent
fbd9f1506f
commit
012595e107
@ -470,7 +470,7 @@ void PresetBundle::load_selections(AppConfig &config, const std::string &preferr
|
||||
void PresetBundle::export_selections(AppConfig &config)
|
||||
{
|
||||
assert(this->printers.get_edited_preset().printer_technology() != ptFFF || filament_presets.size() >= 1);
|
||||
assert(this->printers.get_edited_preset().printer_technology() != ptFFF || filament_presets.size() > 1 || filaments.get_selected_preset_name() == filament_presets.front());
|
||||
//assert(this->printers.get_edited_preset().printer_technology() != ptFFF || filament_presets.size() > 1 || filaments.get_selected_preset_name() == filament_presets.front());
|
||||
config.clear_section("presets");
|
||||
config.set("presets", "print", prints.get_selected_preset_name());
|
||||
config.set("presets", "filament", filament_presets.front());
|
||||
|
@ -3013,7 +3013,9 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
#if ENABLE_REDUCED_TOOLPATHS_SEGMENT_CAPS
|
||||
for (const auto& [tbuffer_id, ibuffer_id, path_id, sub_path_id] : paths) {
|
||||
TBuffer& buffer = const_cast<TBuffer&>(m_buffers[tbuffer_id]);
|
||||
if (buffer.paths.size() <= path_id) return; // invalid data check
|
||||
const Path& path = buffer.paths[path_id];
|
||||
if (m_tool_colors.size() <= path.extruder_id) return; // invalid data check
|
||||
#else
|
||||
for (const auto& [buffer, ibuffer_id, path_id, sub_path_id] : paths) {
|
||||
const Path& path = buffer->paths[path_id];
|
||||
@ -4192,7 +4194,8 @@ void GCodeViewer::render_legend() const
|
||||
{
|
||||
// shows only extruders actually used
|
||||
for (unsigned char i : m_extruder_ids) {
|
||||
append_item(EItemType::Rect, m_tool_colors[i], _u8L("Extruder") + " " + std::to_string(i + 1));
|
||||
if(m_tool_colors.size() > i)
|
||||
append_item(EItemType::Rect, m_tool_colors[i], _u8L("Extruder") + " " + std::to_string(i + 1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -4200,7 +4203,8 @@ void GCodeViewer::render_legend() const
|
||||
{
|
||||
// shows only filament actually used
|
||||
for (unsigned char i : m_extruder_ids) {
|
||||
append_item(EItemType::Rect, m_filament_colors[i], _u8L("Filament") + " " + std::to_string(i + 1));
|
||||
if (m_filament_colors.size() > i)
|
||||
append_item(EItemType::Rect, m_filament_colors[i], _u8L("Filament") + " " + std::to_string(i + 1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -4232,28 +4236,30 @@ void GCodeViewer::render_legend() const
|
||||
{
|
||||
// shows only extruders actually used
|
||||
for (unsigned char i : m_extruder_ids) {
|
||||
std::vector<std::pair<Color, std::pair<double, double>>> cp_values = color_print_ranges(i, custom_gcode_per_print_z);
|
||||
const int items_cnt = static_cast<int>(cp_values.size());
|
||||
if (items_cnt == 0) { // There are no color changes, but there are some pause print or custom Gcode
|
||||
append_item(EItemType::Rect, m_tool_colors[i], _u8L("Extruder") + " " + std::to_string(i + 1) + " " + _u8L("default color"));
|
||||
}
|
||||
else {
|
||||
for (int j = items_cnt; j >= 0; --j) {
|
||||
// create label for color change item
|
||||
std::string label = _u8L("Extruder") + " " + std::to_string(i + 1);
|
||||
if (j == 0) {
|
||||
label += " " + upto_label(cp_values.front().second.first);
|
||||
append_item(EItemType::Rect, m_tool_colors[i], label);
|
||||
break;
|
||||
}
|
||||
else if (j == items_cnt) {
|
||||
label += " " + above_label(cp_values[j - 1].second.second);
|
||||
append_item(EItemType::Rect, cp_values[j - 1].first, label);
|
||||
continue;
|
||||
}
|
||||
if (m_tool_colors.size() > i) {
|
||||
std::vector<std::pair<Color, std::pair<double, double>>> cp_values = color_print_ranges(i, custom_gcode_per_print_z);
|
||||
const int items_cnt = static_cast<int>(cp_values.size());
|
||||
if (items_cnt == 0) { // There are no color changes, but there are some pause print or custom Gcode
|
||||
append_item(EItemType::Rect, m_tool_colors[i], _u8L("Extruder") + " " + std::to_string(i + 1) + " " + _u8L("default color"));
|
||||
}
|
||||
else {
|
||||
for (int j = items_cnt; j >= 0; --j) {
|
||||
// create label for color change item
|
||||
std::string label = _u8L("Extruder") + " " + std::to_string(i + 1);
|
||||
if (j == 0) {
|
||||
label += " " + upto_label(cp_values.front().second.first);
|
||||
append_item(EItemType::Rect, m_tool_colors[i], label);
|
||||
break;
|
||||
}
|
||||
else if (j == items_cnt) {
|
||||
label += " " + above_label(cp_values[j - 1].second.second);
|
||||
append_item(EItemType::Rect, cp_values[j - 1].first, label);
|
||||
continue;
|
||||
}
|
||||
|
||||
label += " " + fromto_label(cp_values[j - 1].second.second, cp_values[j].second.first);
|
||||
append_item(EItemType::Rect, cp_values[j - 1].first, label);
|
||||
label += " " + fromto_label(cp_values[j - 1].second.second, cp_values[j].second.first);
|
||||
append_item(EItemType::Rect, cp_values[j - 1].first, label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5961,7 +5961,15 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
|
||||
{
|
||||
bool update_scheduled = false;
|
||||
bool bed_shape_changed = false;
|
||||
auto diffs = p->config->diff(config);
|
||||
for (auto opt_key : p->config->diff(config)) {
|
||||
if (opt_key == "nozzle_diameter") {
|
||||
if (p->config->option<ConfigOptionFloats>(opt_key)->values.size() > config.option<ConfigOptionFloats>(opt_key)->values.size()) {
|
||||
//lower number of extuders, please don't try to display the old gcode.
|
||||
p->reset_gcode_toolpaths();
|
||||
p->gcode_result.reset();
|
||||
}
|
||||
}
|
||||
if (opt_key == "filament_colour")
|
||||
{
|
||||
update_scheduled = true; // update should be scheduled (for update 3DScene) #2738
|
||||
|
Loading…
x
Reference in New Issue
Block a user