Skip to content

Prevent PresetsWidget internal refreshes from applying configs#558

Merged
tlambert03 merged 1 commit into
pymmcore-plus:mainfrom
gcharvin:fix/preset-combo-internal-signals
May 26, 2026
Merged

Prevent PresetsWidget internal refreshes from applying configs#558
tlambert03 merged 1 commit into
pymmcore-plus:mainfrom
gcharvin:fix/preset-combo-internal-signals

Conversation

@gcharvin

Copy link
Copy Markdown
Contributor

Summary

  • Block PresetsWidget combo signals during the full internal preset-state refresh.
  • Prevent adding/removing <no match> from triggering setConfig().
  • Add a regression test for the <no match> -> preset transition.

Motivation

When PresetsWidget refreshes after core property changes, removing the currently selected <no match> item can emit currentTextChanged. Since _on_combo_changed() calls mmc.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 in signals_blocked(self._combo), including removeItem, addItem, and setCurrentText.

This matches the existing pattern used by ChannelGroupWidget.

Tests

  • ruff check src/pymmcore_widgets/control/_presets_widget.py tests/test_presets_widget.py
  • ruff format --check src/pymmcore_widgets/control/_presets_widget.py tests/test_presets_widget.py
  • pytest tests/test_presets_widget.py tests/test_channel_widget.py tests/test_group_preset_widget.py -q

@tlambert03 tlambert03 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. thank you!

@tlambert03 tlambert03 enabled auto-merge (squash) May 26, 2026 13:28
@tlambert03 tlambert03 merged commit ec9e89a into pymmcore-plus:main May 26, 2026
23 checks passed
@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.43%. Comparing base (48ff414) to head (636fd02).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants