From 7125a546b8d549d021ca64401af059e2eef4e17a Mon Sep 17 00:00:00 2001 From: Eric Lin <17968842+anselor@users.noreply.github.com> Date: Tue, 27 Oct 2026 11:53:44 -0400 Subject: [PATCH] Fix Slice sometimes needing a second click (#15180) The GUI re-applies the unchanged config after every slice. filament_map, filament_volume_map and filament_nozzle_map are adopted from the new config but were left in full_config_diff, because the erase was commented out. That invalidated psGCodeExport on every reapply, so the slice that had just finished was thrown away. Erase them from full_config_diff too, including filament_nozzle_map in manual map mode. --- src/libslic3r/PrintApply.cpp | 7 ++++--- tests/fff_print/test_multifilament.cpp | 27 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index a6a78e393d..389db20896 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1522,7 +1522,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ if (is_auto_filament_map_mode(map_mode)) { if (print_diff_set.find("filament_map") != print_diff_set.end()) { print_diff_set.erase("filament_map"); - //full_config_diff.erase("filament_map"); + full_config_diff.erase(std::remove(full_config_diff.begin(), full_config_diff.end(), "filament_map"), full_config_diff.end()); ConfigOptionInts* old_opt = m_full_print_config.option("filament_map", true); ConfigOptionInts* new_opt = new_full_config.option("filament_map", true); old_opt->set(new_opt); @@ -1530,7 +1530,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ } if (print_diff_set.find("filament_volume_map") != print_diff_set.end()) { print_diff_set.erase("filament_volume_map"); - //full_config_diff.erase("filament_volume_map"); + full_config_diff.erase(std::remove(full_config_diff.begin(), full_config_diff.end(), "filament_volume_map"), full_config_diff.end()); ConfigOptionInts* old_opt = m_full_print_config.option("filament_volume_map", true); ConfigOptionInts* new_opt = new_full_config.option("filament_volume_map", true); old_opt->set(new_opt); @@ -1538,7 +1538,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ } if (print_diff_set.find("filament_nozzle_map") != print_diff_set.end()) { print_diff_set.erase("filament_nozzle_map"); - //full_config_diff.erase("filament_nozzle_map"); + full_config_diff.erase(std::remove(full_config_diff.begin(), full_config_diff.end(), "filament_nozzle_map"), full_config_diff.end()); ConfigOptionInts* old_opt = m_full_print_config.option("filament_nozzle_map", true); ConfigOptionInts* new_opt = new_full_config.option("filament_nozzle_map", true); old_opt->set(new_opt); @@ -1550,6 +1550,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ if (map_mode == fmmManual) { // filament_nozzle_map is an engine output, not a GUI input, in manual mode print_diff_set.erase("filament_nozzle_map"); + full_config_diff.erase(std::remove(full_config_diff.begin(), full_config_diff.end(), "filament_nozzle_map"), full_config_diff.end()); } std::vector old_filament_map = m_config.filament_map.values; std::vector new_filament_map = new_full_config.option("filament_map", true)->values; diff --git a/tests/fff_print/test_multifilament.cpp b/tests/fff_print/test_multifilament.cpp index b954e3d20a..4a9900d60a 100644 --- a/tests/fff_print/test_multifilament.cpp +++ b/tests/fff_print/test_multifilament.cpp @@ -2137,6 +2137,33 @@ TEST_CASE("Unused extruder turns off on non-IMEX three-tool print", "[MultiFilam CHECK_FALSE(premature_s0_t2); } +// The GUI re-applies the unchanged config after every slice; that must not invalidate it. +TEST_CASE("Reapplying an unchanged config after slicing reports no change", "[MultiFilament]") { + DynamicPrintConfig config = multifilament_config(2, { + { "wall_filament", "1" }, + { "sparse_infill_filament", "2" }, + { "solid_infill_filament", "2" }, + { "enable_prime_tower", "1" }, + { "independent_support_layer_height", "1" }, + { "wipe_tower_x", "50" }, + { "wipe_tower_y", "50" }, + // init_print sets it, so the reapply differs only in what apply() itself normalizes. + { "gcode_comments", "1" }, + }); + Model model; + Print print; + Slic3r::Test::init_print({ TestMesh::cube_with_hole }, print, model, config); + print.process(); + const bool ept_before = print.config().enable_prime_tower.value; + const bool islh_before = print.config().independent_support_layer_height.value; + + const auto status = print.apply(model, config); + + CHECK(print.config().enable_prime_tower.value == ept_before); + CHECK(print.config().independent_support_layer_height.value == islh_before); + CHECK(status == PrintBase::APPLY_STATUS_UNCHANGED); +} + static DynamicPrintConfig short_change_length_config() { DynamicPrintConfig config = multifilament_config(2, { // One value for two filaments: the tower must not read past it.