diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index f46297855d..7f9a2020df 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -1707,11 +1707,13 @@ int CLI::run(int argc, char **argv) BOOST_LOG_TRIVIAL(info) << boost::format("current_printer_name %1%, current_process_name %2%")%current_printer_name %current_process_name; ConfigOptionStrings* option_strings = config.option("inherits_group"); - // One entry for the process, one per filament and one for the printer. + // One entry for the process, one per filament and one for the printer. A group of another + // length still has the process first and the printer last; one too short for that is ignored. if (option_strings && option_strings->values.size() != current_filaments_name.size() + 2) { - boost::nowide::cerr << "Warning: ignoring inherits_group with " << option_strings->values.size() << " entries, expected " + boost::nowide::cerr << "Warning: inherits_group has " << option_strings->values.size() << " entries, expected " << current_filaments_name.size() + 2 << " for " << current_filaments_name.size() << " filaments" << std::endl; - option_strings = nullptr; + if (option_strings->values.size() < 2) + option_strings = nullptr; } if (option_strings) { current_inherits_group = option_strings->values; @@ -1734,14 +1736,11 @@ int CLI::run(int argc, char **argv) BOOST_LOG_TRIVIAL(info) << boost::format("inherits of process valid, current_process_system_name is %1%") %current_process_system_name; } - current_filaments_system_name.resize(size - 2); - for (int index = 1; index < (size - 1); index++) { - if (current_inherits_group[index].empty()) { - current_filaments_system_name[index-1] = current_filaments_name[index-1]; - } - else { + // A filament without an entry of its own counts as a system preset. + current_filaments_system_name = current_filaments_name; + for (size_t index = 1; index < size - 1 && index <= current_filaments_name.size(); index++) { + if (!current_inherits_group[index].empty()) current_filaments_system_name[index-1] = current_inherits_group[index]; - } } } else { diff --git a/tests/cli/test_cli_malformed_input.sh b/tests/cli/test_cli_malformed_input.sh index ea96251dd6..b6899a301f 100644 --- a/tests/cli/test_cli_malformed_input.sh +++ b/tests/cli/test_cli_malformed_input.sh @@ -3,7 +3,7 @@ # orca-slicer binary. Each case lives inline in CLI::run(), so only the binary can reach it. # # - A project whose inherits_group does not have one entry per filament plus the process and -# printer entries is loaded as if it had none. +# printer entries still loads. # - --slice N --arrange 1 on a project without plate metadata slices plate N. # - An assemble list object with an empty filament list, or a negative filament id, is rejected # as a config error. @@ -155,7 +155,7 @@ run_presets export --slice 0 --export-3mf project.3mf "$WORK/cube.stl" expect_status export $CLI_SUCCESS [ -f "$WORK/export/project.3mf" ] || { echo "FAIL: project export failed"; tail -n 40 "$WORK/export/log"; exit 1; } -echo "== an inherits_group of the wrong length is ignored" +echo "== an inherits_group of the wrong length still loads" for group in '[]' '[""]' '["", "", "", "", ""]'; do tag="inherits_$("$PY" -c 'import json, sys; print(len(json.loads(sys.argv[1])))' "$group")" rewrite_3mf "$WORK/export/project.3mf" "$WORK/$tag.3mf" inherits "$group"