Fix for #13038 - Fix a crash when loading tool changes for not-existing extruder

This commit is contained in:
YuSanka 2024-07-10 14:39:31 +02:00 committed by Lukas Matena
parent f86d329a70
commit d9ef0f1781
3 changed files with 10 additions and 0 deletions

View File

@ -1248,6 +1248,9 @@ std::string DSForLayers::get_tooltip(int tick/*=-1*/)
else if (conflict == ctMeaninglessToolChange)
tooltip += _u8L("There is an extruder change set to the same extruder.\n"
"This code won't be processed during G-code generation.");
else if (conflict == ctNotPossibleToolChange)
tooltip += _u8L("There is an extruder change set to the not existing extruder.\n"
"This code won't be processed during G-code generation.");
else if (conflict == ctRedundant)
tooltip += _u8L("There is a color change for extruder that has not been used before.\n"
"Check your settings to avoid redundant color changes.");

View File

@ -659,6 +659,9 @@ ConflictType TickCodeManager::is_conflict_tick(const TickCode& tick, Mode main_m
// We should mark a tick as a "MeaninglessToolChange",
// if it has a ToolChange to the same extruder
auto it = ticks.find(tick);
if (it->extruder > colors.size())
return ctNotPossibleToolChange;
if (it == ticks.begin())
return tick.extruder == std::max<int>(only_extruder_id, 1) ? ctMeaninglessToolChange : ctNone;
@ -676,6 +679,9 @@ std::string TickCodeManager::get_color_for_tool_change_tick(std::set<TickCode>::
{
const int current_extruder = it->extruder == 0 ? std::max<int>(only_extruder_id, 1) : it->extruder;
if (current_extruder > colors.size())
return it->color;
auto it_n = it;
while (it_n != ticks.begin()) {
--it_n;

View File

@ -37,6 +37,7 @@ enum ConflictType
ctModeConflict,
ctMeaninglessColorChange,
ctMeaninglessToolChange,
ctNotPossibleToolChange,
ctRedundant
};