Skip to content

fix: state device widget init signal block#557

Merged
tlambert03 merged 2 commits into
pymmcore-plus:mainfrom
hinderling:fix/state-device-widget-init-signal-block
May 15, 2026
Merged

fix: state device widget init signal block#557
tlambert03 merged 2 commits into
pymmcore-plus:mainfrom
hinderling:fix/state-device-widget-init-signal-block

Conversation

@hinderling
Copy link
Copy Markdown
Contributor

Issue: The initial setCurrentText fired currentIndexChanged -> _on_combo_changed -> mmc.setState() for the already-current state. On Nikon TI scopes that re-applies the objective turret preset on widget init, the turret "rotates" to its current position, and PFS gets disabled.

Fix: Block signals around the initial sync, matching the pattern already used in _refresh_choices and _on_sys_cfg_loaded.

Tested: With Nikon TI when opening napari-micromanager, the PFS stays enabled and turret doesn't "move".

Also added the same signal blocker to _device_widget.py for completeness. (No device settings changed there, but extra loop of setting default stage device)

The initial setCurrentText fired currentIndexChanged ->
_on_combo_changed -> mmc.setState() for the already-current state. On
Nikon TI scopes that re-applies the objective turret preset on widget
init: Z drops, PFS disables, the turret "rotates" to its current
position, Z raises. Hardware moves before the user touches anything.

Block signals around the initial sync, matching the pattern already
used in _refresh_choices and _on_sys_cfg_loaded.
_set_as_default() calls _set_as_default_btn.setChecked(True) without
signals_blocked, which fires the toggled signal ->
_on_radiobutton_toggled -> mmc.setProperty(CORE, XY_STAGE/Focus,
self._device). On construction, if the device is already the default
stage in core, the widget writes the same value back to core, firing a
propertyChanged ripple. No hardware motion, but the same init-side-
effect anti-pattern as the StateDeviceWidget fix.

Block signals around the setChecked calls, matching the pattern used
elsewhere in the same widget (_on_radiobutton_toggled,
_on_prop_changed).
@hinderling hinderling changed the title Fix/state device widget init signal block fix: state device widget init signal block May 14, 2026
@tlambert03
Copy link
Copy Markdown
Member

thanks!

@tlambert03 tlambert03 enabled auto-merge (squash) May 15, 2026 12:08
@tlambert03 tlambert03 merged commit 48ff414 into pymmcore-plus:main May 15, 2026
21 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.42%. Comparing base (ade9125) to head (0b75db1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #557      +/-   ##
==========================================
- Coverage   87.43%   87.42%   -0.02%     
==========================================
  Files         115      115              
  Lines       14093    14095       +2     
==========================================
  Hits        12322    12322              
- Misses       1771     1773       +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