fix(slicer): invalidate slice result when instance printability toggles#10892
Open
adele-with-a-b wants to merge 1 commit into
Open
fix(slicer): invalidate slice result when instance printability toggles#10892adele-with-a-b wants to merge 1 commit into
adele-with-a-b wants to merge 1 commit into
Conversation
Contributor
|
Heads-up: this build failure doesn't come from this PR. The Assimp bundles an old zlib ( |
When a user toggles an object instance's 'Printable' flag, the slice button stays grayed out and clicking it has no effect, even though the toggle visually registers in the object list. Root cause: Plater::priv::update_background_process only calls update_slice_result_valid_state(false) when Print::apply() returns APPLY_STATUS_INVALIDATED — APPLY_STATUS_CHANGED is not enough (Plater.cpp:10210). In Print::apply()'s instance synchronization branch (PrintApply.cpp ~line 1757), the loop updates each instance's printable flag but only invalidates Print steps when is_printable_filament_changed() detects a filament-set change. A pure printability toggle that does not alter the filament assignment produces no invalidation in this loop. Section 4's PrintObject reconciliation does eventually fire invalidate_all_steps() for objects whose printable instance count changed — but in the affected workflow the print steps are already in INVALID state from earlier background-process activity, so invalidate_all_steps() returns false and the overall apply_status caps at APPLY_STATUS_CHANGED (1) rather than rising to APPLY_STATUS_INVALIDATED (2). Result: 1. update_slice_result_valid_state(false) is NOT called. 2. PartPlate::is_slice_result_valid() stays true. 3. MainFrame::get_enable_slice_status() returns false (button stays disabled) because the plate's slice result is still considered valid and there is nothing new to slice. 4. The user sees a grayed-out slice button after toggling. Reproducible with logs: every printability toggle in the affected configuration produces 'background process apply result=1' (APPLY_STATUS_CHANGED) followed by enable_slice=0 in update_slice_print_status. After the patch the same toggle produces 'apply result=2' (APPLY_STATUS_INVALIDATED) and enable_slice=1. Regression context: e22d328 ('ENH: Optimizing the shape invalid condition for wipe tower of multi-extruder', May 2025) replaced an unconditional invalidation in the set_instances path with a narrower convex-hull-based check. The optimization was correct for translation/rotation cases, but printability toggles do not change geometry, so they fall through both the new and old checks in this loop. Fix: invalidate {psSkirtBrim, psWipeTower, psGCodeExport} whenever old_instance->printable != new_instance->printable. This matches the triplet used elsewhere in PrintApply.cpp (line 1852) and in PrintObject::set_instances (PrintObject.cpp:116). Skirt/brim is included because the set of PrintInstances feeding Print::_make_skirt is filtered upstream by ModelInstance::is_printable() at PrintApply.cpp:147 — when printability toggles, the cached skirt geometry is stale and must be recomputed. When the loop's invalidation actually flips a step from VALID to INVALID (the typical case after a fresh slice), this lifts apply_status to APPLY_STATUS_INVALIDATED and the cached slice result is correctly marked stale, re-enabling the slice button.
b6906c7 to
8f4f0e8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a regression where toggling an object instance's "Printable" flag leaves the slice button grayed out, requiring an unrelated change to the project before the user can re-slice.
Closes #10891
Root cause
Print::apply()'s instance synchronization branch (src/libslic3r/PrintApply.cpp~line 1757) updates each instance'sprintableflag but only invalidates Print steps whenis_printable_filament_changed()detects a filament-set change. A pure printability toggle leaves the filament assignment unchanged, so this loop produces no invalidation.Section 4 of
Print::applydoes fireinvalidate_all_steps()for the toggled object, but in the affected workflow the print steps are already in INVALID state from earlier background-process activity, soinvalidate_all_steps()returns false and the overallapply_statuscaps atAPPLY_STATUS_CHANGED(1) instead ofAPPLY_STATUS_INVALIDATED(2).Plater::priv::update_background_processonly callsupdate_slice_result_valid_state(false)onAPPLY_STATUS_INVALIDATED(Plater.cpp:10210). WithAPPLY_STATUS_CHANGED, the cached slice result stays valid, soMainFrame::get_enable_slice_status()returns false (button disabled) becausePartPlate::is_slice_result_valid()is still true.Regression
Introduced by
e22d328f("ENH: Optimizing the shape invalid condition for wipe tower of multi-extruder", May 2025), which replaced an unconditional invalidation in theset_instancespath with a narrower convex-hull-based check. The optimization was correct for translation/rotation cases, but printability toggles do not change geometry, so they fall through both the new and old checks in this loop.Fix
Invalidate
{psSkirtBrim, psWipeTower, psGCodeExport}wheneverold_instance->printable != new_instance->printable. The triplet matches the one used elsewhere inPrintApply.cpp(line 1852) and inPrintObject::set_instances(PrintObject.cpp:116).Skirt/brim is included because the set of
PrintInstances feedingPrint::_make_skirtis filtered upstream byModelInstance::is_printable()atPrintApply.cpp:147— when printability toggles, the cached skirt geometry is stale.The diff is 4 lines.
Test plan
BBL_INTERNAL_TESTING=1build that pre-patch toggle producesapply_status=1(CHANGED) andenable_slice=0, while post-patch the same toggle producesapply_status=2(INVALIDATED) andenable_slice=1.is_printable_filament_changedpath and behave ase22d328fintended.