Prevent PresetsWidget internal refreshes from applying configs#558
Merged
tlambert03 merged 1 commit intoMay 26, 2026
Merged
Conversation
tlambert03
approved these changes
May 26, 2026
tlambert03
left a comment
Member
There was a problem hiding this comment.
looks good to me. thank you!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #558 +/- ##
==========================================
+ Coverage 87.42% 87.43% +0.01%
==========================================
Files 115 115
Lines 14095 14094 -1
==========================================
+ Hits 12322 12323 +1
+ Misses 1773 1771 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
PresetsWidgetcombo signals during the full internal preset-state refresh.<no match>from triggeringsetConfig().<no match>-> preset transition.Motivation
When
PresetsWidgetrefreshes after core property changes, removing the currently selected<no match>item can emitcurrentTextChanged. Since_on_combo_changed()callsmmc.setConfig(), an internal UI refresh may accidentally apply a hardware preset.This was observed during MDA channel switching, where transient non-matching device states could cause an unintended channel preset to be selected. The issue is generic Qt signal reentrancy, not microscope-specific.
There is no screenshot attached because this is not a visual rendering change: the problematic behavior is an internal Qt signal emitted during combo-box synchronization. The regression test captures the behavior directly by asserting that the UI refresh does not emit
configSet.Fix
Wrap the entire
_update_if_props_not_match_preset()combo synchronization insignals_blocked(self._combo), includingremoveItem,addItem, andsetCurrentText.This matches the existing pattern used by
ChannelGroupWidget.Tests
ruff check src/pymmcore_widgets/control/_presets_widget.py tests/test_presets_widget.pyruff format --check src/pymmcore_widgets/control/_presets_widget.py tests/test_presets_widget.pypytest tests/test_presets_widget.py tests/test_channel_widget.py tests/test_group_preset_widget.py -q