mantidproject / mantidimaging

Graphical toolkit for neutron imaging.
https://mantidproject.github.io/mantidimaging
GNU General Public License v3.0
10 stars 6 forks source link

Spectrum Viewer KeyError when no stacks available #2242

Open MikeSullivan7 opened 1 week ago

MikeSullivan7 commented 1 week ago

Summary

If the Spectrum Viewer is open and all datasets are deleted, then switching to the RITS ROI tab gives a KeyError.

Steps To Reproduce

  1. Load a dataset into MI
  2. Open the Spectrum Viewer
  3. Delete all datasets in the Main Window such that no Image Stacks are available in the Spectrum Viewer
  4. Switch to the RITS "Image" tab

Expected Behaviour

Either the tabs should grey out or just no data is displayed

Current Behaviour

MI gives a KeyError for the rits_roi ROI

Failure Logs

2024-06-27 15:56:08,567 [mantidimaging.gui.windows.main.view:L568] ERROR: Traceback (most recent call last):
  File "C:\Users\ddb29996\mantidimaging\mantidimaging\gui\windows\spectrum_viewer\presenter.py", line 387, in handle_export_tab_change
    self.view.on_visibility_change()
  File "C:\Users\ddb29996\mantidimaging\mantidimaging\gui\windows\spectrum_viewer\view.py", line 260, in on_visibility_change
    self.set_roi_alpha(255, ROI_RITS)
  File "C:\Users\ddb29996\mantidimaging\mantidimaging\gui\windows\spectrum_viewer\view.py", line 425, in set_roi_alpha
    self.spectrum_widget.set_roi_alpha(roi_name, alpha)
  File "C:\Users\ddb29996\mantidimaging\mantidimaging\gui\windows\spectrum_viewer\spectrum_widget.py", line 197, in set_roi_alpha
    self.roi_dict[name].colour = self.roi_dict[name].colour[:3] + (alpha, )
KeyError: 'rits_roi'

2024-06-27 15:56:08,568 [mantidimaging.gui.mvp_base.view:L46] ERROR: show_error_dialog(): Uncaught exception KeyError: 'rits_roi'

Screenshot(s)

image

image