Skip to content

Commit

Permalink
Backport PR #2541: Don't try to update viewer state if it was deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen authored and meeseeksmachine committed Nov 1, 2023
1 parent 5e5a03a commit f72981e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Cubeviz
Imviz
^^^^^

- Plot options layer selection no longer gets stuck in some cases when deleting
the currently selected viewer. [#2541]

Mosviz
^^^^^^

Expand Down
3 changes: 2 additions & 1 deletion jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ def _update_stretch_histogram(self, msg={}):
viewer_label_old = msg.get('old')
if isinstance(viewer_label_old, list):
viewer_label_old = viewer_label_old[0]
if len(viewer_label_old):
# If the previously selected viewer was deleted, we don't need to do this.
if viewer_label_old in self.app._viewer_store:
vs_old = self.app.get_viewer(viewer_label_old).state
for attr in ('x_min', 'x_max', 'y_min', 'y_max'):
vs_old.remove_callback(attr, self._update_stretch_histogram)
Expand Down
15 changes: 15 additions & 0 deletions jdaviz/configs/imviz/tests/test_viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from jdaviz.core.config import get_configuration
from jdaviz.configs.imviz.helper import Imviz
from jdaviz.configs.imviz.plugins.viewers import ImvizImageView
from jdaviz.configs.imviz.tests.utils import BaseImviz_WCS_NoWCS


@pytest.mark.parametrize(
Expand Down Expand Up @@ -94,3 +95,17 @@ def test_mastviz_config():

assert im.app.get_viewer_ids() == ['mastviz-0']
assert im.app.data_collection[0].shape == (2, 2)


class TestDeleteData(BaseImviz_WCS_NoWCS):

def test_plot_options_after_destroy(self):
self.imviz.create_image_viewer(viewer_name="imviz-1")
self.imviz.app.add_data_to_viewer('imviz-1', 'no_wcs[SCI,1]')

po = self.imviz.plugins['Plot Options']
po.open_in_tray()
po.viewer = "imviz-1"
po.stretch_function = "Square Root"
self.imviz.destroy_viewer("imviz-1")
assert len(po.layer.choices) == 2

0 comments on commit f72981e

Please sign in to comment.