-
Notifications
You must be signed in to change notification settings - Fork 41
[fix] GUI stream controller: make sure all subscriptions are cancelled when stream panel is deleted #3568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[fix] GUI stream controller: make sure all subscriptions are cancelled when stream panel is deleted #3568
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,15 +204,14 @@ def __init__(self, stream_bar, stream, tab_data_model, show_panel=True, view=Non | |
| self.tab_data_model.zPos.subscribe(self._on_z_pos, init=True) | ||
|
|
||
| if hasattr(stream, "zIndex") and hasattr(stream, "max_projection"): | ||
| self.zindex_se = None | ||
| # Disable the z-index control when MIP is enabled | ||
| for se in self.entries: | ||
| if se.vigilattr is self.stream.zIndex: | ||
| self._zindex_se = se | ||
| self.stream.max_projection.subscribe(self._on_max_projection) | ||
| break | ||
|
|
||
| if self.zindex_se is None: | ||
| else: | ||
| logging.warning("Stream has zIndex but no corresponding stream entry found.") | ||
| self.stream.max_projection.subscribe(self._on_max_projection) | ||
|
|
||
| # For Temporal Spectrum streams, with a photon counting mode, show/hide the exposure time controls | ||
| if hasattr(stream, "detPhotonCounting"): | ||
|
|
@@ -255,6 +254,16 @@ def _on_stream_panel_destroy(self): | |
| self.stream.detPhotonCounting.unsubscribe(self._on_photon_counting) | ||
| if hasattr(self.stream, "repetition"): | ||
| self.stream.repetition.unsubscribe(self._onStreamRep) | ||
| if hasattr(self.stream, "spectrumBandwidth"): | ||
| self.mean_spec_proj.image.unsubscribe(self._on_new_spec_data) | ||
| del self.mean_spec_proj # Make sure the projection is destroyed | ||
| if hasattr(self.stream, "zIndex"): | ||
| if hasattr(self.tab_data_model, "zPos"): | ||
| self.stream.zIndex.unsubscribe(self._on_z_index) | ||
| self.tab_data_model.zPos.unsubscribe(self._on_z_pos) | ||
| if hasattr(self.stream, "max_projection"): | ||
| self.stream.max_projection.unsubscribe(self._on_max_projection) | ||
| self._zindex_se = None | ||
|
|
||
| # Unsubscribe from all the VAs | ||
| # TODO: it seems that in some cases we still receive a call after destruction | ||
|
|
@@ -548,8 +557,7 @@ def _on_z_pos(self, zPos): | |
| @call_in_wx_main | ||
| def _on_max_projection(self, val): | ||
| """Disable/enable the z-index control based on the max_projection setting""" | ||
| if self._zindex_se is not None: | ||
| self._zindex_se.value_ctrl.Enable(not val) | ||
| self._zindex_se.value_ctrl.Enable(not val) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 15 \
'\bdef call_in_wx_main\b|wx\.CallAfter|wx\.CallLater' \
src/odemisRepository: delmic/odemis Length of output: 50370 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- stream.py changed paths and lifecycle ---'
sed -n '185,280p;535,575p;720,765p' src/odemis/gui/cont/stream.py
printf '%s\n' '--- call_in_wx_main implementation ---'
sed -n '35,90p' src/odemis/gui/util/__init__.py
printf '%s\n' '--- relevant symbols and teardown callers ---'
rg -n -C 4 '_zindex_se|_on_max_projection|call_in_wx_main|destroy|_unlink_resolution|subscribe|unsubscribe' \
src/odemis/gui/cont/stream.pyRepository: delmic/odemis Length of output: 20928 Guard
🤖 Prompt for AI Agents |
||
|
|
||
|
pieleric marked this conversation as resolved.
|
||
| @call_in_wx_main | ||
| def _on_photon_counting(self, active: bool) -> None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: delmic/odemis
Length of output: 50370
🏁 Script executed:
Repository: delmic/odemis
Length of output: 9620
🤖 get_repo_knowledge executed:
get_repo_knowledge delmic/odemis /tmp/coderabbit-repo-knowledge/delmic-odemis-bae42ded/learnings /tmp/coderabbit-repo-knowledge/delmic-odemis-bae42ded/conventionsLength of output: 7195
🏁 Script executed:
Repository: delmic/odemis
Length of output: 15648
Initialize the z-index control from the current projection state.
subscribeinvokes the listener only wheninit=True. Ifstream.max_projection.valueis alreadyTrue, the z-index control remains enabled until the value changes. Passinit=Trueor invoke_on_max_projectionafter assigning_zindex_se.🤖 Prompt for AI Agents